Thu, 06 Feb 2020 20:33:05 +0200
added the pick scene
17 | 1 | #pragma once |
2 | #include <QOpenGLWidget> | |
3 | #include <QOpenGLFunctions> | |
4 | #include <QQuaternion> | |
26 | 5 | #include <QOpenGLVertexArrayObject> |
6 | #include <QOpenGLBuffer> | |
7 | #include <QOpenGLShader> | |
8 | #include <QOpenGLShaderProgram> | |
28 | 9 | #include <glm/glm.hpp> |
17 | 10 | #include "main.h" |
18 | 11 | #include "gl/common.h" |
21 | 12 | #include "gl/compiler.h" |
17 | 13 | |
14 | class PartRenderer : public QOpenGLWidget, protected QOpenGLFunctions | |
15 | { | |
21 | 16 | Q_OBJECT |
17 | 17 | public: |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
34
diff
changeset
|
18 | PartRenderer( |
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
34
diff
changeset
|
19 | Model* model, |
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
34
diff
changeset
|
20 | DocumentManager* documents, |
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
34
diff
changeset
|
21 | const ldraw::ColorTable& colorTable, |
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
34
diff
changeset
|
22 | QWidget* parent = nullptr); |
26 | 23 | ~PartRenderer() override; |
39
caac957e9834
Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents:
37
diff
changeset
|
24 | void setRenderPreferences(const gl::RenderPreferences& newPreferences); |
17 | 25 | protected: |
26 | void initializeGL() override; | |
27 | void resizeGL(int width, int height) override; | |
28 | void paintGL() override; | |
29 | void mouseMoveEvent(QMouseEvent* event) override; | |
31
b6df269a2c6b
fix remaining rendering control issues
Teemu Piippo <teemu@hecknology.net>
parents:
30
diff
changeset
|
30 | void wheelEvent(QWheelEvent* event) override; |
17 | 31 | private: |
37 | 32 | void setFragmentStyle(gl::FragmentStyle fragStyle); |
33 | void renderAllArrays(); | |
22
6da867fa5429
commit work on GL rendering
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
34 | void renderScene(); |
31
b6df269a2c6b
fix remaining rendering control issues
Teemu Piippo <teemu@hecknology.net>
parents:
30
diff
changeset
|
35 | void updateViewMatrix(); |
21 | 36 | Model* const model; |
37 | DocumentManager* const documents; | |
35
98906a94732f
renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents:
34
diff
changeset
|
38 | const ldraw::ColorTable& colorTable; |
17 | 39 | QPointF lastMousePosition; |
22
6da867fa5429
commit work on GL rendering
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
40 | gl::Compiler* compiler; |
39
caac957e9834
Main color is now configurable
Teemu Piippo <teemu@hecknology.net>
parents:
37
diff
changeset
|
41 | gl::RenderPreferences renderPreferences; |
28 | 42 | glm::mat4 projectionMatrix; |
43 | glm::mat4 viewMatrix; | |
31
b6df269a2c6b
fix remaining rendering control issues
Teemu Piippo <teemu@hecknology.net>
parents:
30
diff
changeset
|
44 | glm::quat modelQuaternion; |
b6df269a2c6b
fix remaining rendering control issues
Teemu Piippo <teemu@hecknology.net>
parents:
30
diff
changeset
|
45 | static constexpr double MIN_ZOOM = 0.0; |
b6df269a2c6b
fix remaining rendering control issues
Teemu Piippo <teemu@hecknology.net>
parents:
30
diff
changeset
|
46 | static constexpr double MAX_ZOOM = 3.0; |
b6df269a2c6b
fix remaining rendering control issues
Teemu Piippo <teemu@hecknology.net>
parents:
30
diff
changeset
|
47 | double zoom = 1.0; |
22
6da867fa5429
commit work on GL rendering
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
48 | bool initialized = false; |
26 | 49 | void renderVao(const gl::ArrayClass arrayClass); |
50 | void checkForGLErrors(); | |
17 | 51 | }; |