Debian Codegraph @

src/qvrapp.hpp

raw
1 /*
2 * This file is part of Bino, a 3D video player.
3 *
4 * Copyright (C) 2022, 2023, 2024, 2025, 2026
5 * Martin Lambers <[email protected]>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #pragma once
22
23 #ifdef WITH_QVR
24
25 #include <QOpenGLExtraFunctions>
26 #include <QOpenGLShaderProgram>
27
28 #include <qvr/app.hpp>
29
30
31 class BinoQVRApp : public QVRApp, protected QOpenGLExtraFunctions
32 {
33 private:
34 /* Static per-process data for rendering */
35 bool _haveAnisotropicFiltering;
36 QOpenGLShaderProgram _prg;
37 // Data to render device models
38 bool _renderDevices;
39 QVector<unsigned int> _devModelVaos;
40 QVector<unsigned int> _devModelVaoIndices;
41 QVector<unsigned int> _devModelTextures;
42
43 /* Helper function for texture loading */
44 unsigned int setupTex(const QImage& img);
45 /* Helper function for VAO setup */
46 unsigned int setupVao(int vertexCount,
47 const float* positions, const float* normals, const float* texcoords,
48 int indexCount, const unsigned short* indices);
49
50 public:
51 BinoQVRApp(bool renderDevices);
52
53 void serializeStaticData(QDataStream& ds) const override;
54 void deserializeStaticData(QDataStream& ds) override;
55
56 void serializeDynamicData(QDataStream& ds) const override;
57 void deserializeDynamicData(QDataStream& ds) override;
58
59 bool wantExit() override;
60
61 bool initProcess(QVRProcess* p) override;
62
63 void preRenderProcess(QVRProcess* p) override;
64
65 void render(QVRWindow* w, const QVRRenderContext& c, const unsigned int* textures) override;
66
67 void keyPressEvent(const QVRRenderContext& context, QKeyEvent* event) override;
68 };
69
70 #endif