Tue, 28 Sep 2021 23:09:09 +0300
remove outdated comment
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); |
107
02f142b399b1
Move selection logic into select tool
Teemu Piippo <teemu@hecknology.net>
parents:
86
diff
changeset
|
25 | ldraw::id_t getHighlightedObject() const; |
17 | 26 | protected: |
73
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
71
diff
changeset
|
27 | ldraw::id_t pick(const QPoint& where); |
17 | 28 | void initializeGL() override; |
29 | void resizeGL(int width, int height) override; | |
30 | void paintGL() override; | |
31 | void mouseMoveEvent(QMouseEvent* event) override; | |
31
b6df269a2c6b
fix remaining rendering control issues
Teemu Piippo <teemu@hecknology.net>
parents:
30
diff
changeset
|
32 | void wheelEvent(QWheelEvent* event) override; |
51 | 33 | Model* const model; |
34 | DocumentManager* const documents; | |
35 | const ldraw::ColorTable& colorTable; | |
36 | gl::Compiler* const compiler; | |
73
97df974b5ed5
ldraw::Id is now templated for extra type safety
Teemu Piippo <teemu@hecknology.net>
parents:
71
diff
changeset
|
37 | ldraw::id_t highlighted = ldraw::NULL_ID; |
66
77c819262b7a
added a method to find out if the view is perpendicular to grid
Teemu Piippo <teemu@hecknology.net>
parents:
61
diff
changeset
|
38 | std::optional<glm::vec3> screenToModelCoordinates(const QPoint& point, const geom::Plane& plane) const; |
77c819262b7a
added a method to find out if the view is perpendicular to grid
Teemu Piippo <teemu@hecknology.net>
parents:
61
diff
changeset
|
39 | QPointF modelToScreenCoordinates(const glm::vec3& point) const; |
71
198d25fe4e21
show axis directions on the screen
Teemu Piippo <teemu@hecknology.net>
parents:
70
diff
changeset
|
40 | geom::Line<3> cameraLine(const QPoint& point) const; |
66
77c819262b7a
added a method to find out if the view is perpendicular to grid
Teemu Piippo <teemu@hecknology.net>
parents:
61
diff
changeset
|
41 | glm::vec3 unproject(const glm::vec3& win) const; |
61
4585d8d7a7ec
moved GridProgram to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
58
diff
changeset
|
42 | glm::mat4 projectionMatrix; |
4585d8d7a7ec
moved GridProgram to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
58
diff
changeset
|
43 | glm::mat4 viewMatrix; |
4585d8d7a7ec
moved GridProgram to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
58
diff
changeset
|
44 | glm::mat4 modelMatrix; |
4585d8d7a7ec
moved GridProgram to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
58
diff
changeset
|
45 | glm::vec4 viewportVector; |
4585d8d7a7ec
moved GridProgram to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
58
diff
changeset
|
46 | glm::quat modelQuaternion; |
4585d8d7a7ec
moved GridProgram to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
58
diff
changeset
|
47 | QPoint lastMousePosition; |
4585d8d7a7ec
moved GridProgram to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
58
diff
changeset
|
48 | gl::RenderPreferences renderPreferences; |
112 | 49 | Q_SIGNALS: |
70 | 50 | void projectionMatrixChanged(const glm::mat4& newMatrix); |
51 | void modelMatrixChanged(const glm::mat4& newMatrix); | |
52 | void viewMatrixChanged(const glm::mat4& newMatrix); | |
61
4585d8d7a7ec
moved GridProgram to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
58
diff
changeset
|
53 | void renderPreferencesChanged(); |
17 | 54 | private: |
37 | 55 | void setFragmentStyle(gl::FragmentStyle fragStyle); |
56 | void renderAllArrays(); | |
22
6da867fa5429
commit work on GL rendering
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
57 | void renderScene(); |
31
b6df269a2c6b
fix remaining rendering control issues
Teemu Piippo <teemu@hecknology.net>
parents:
30
diff
changeset
|
58 | void updateViewMatrix(); |
55 | 59 | void updateModelMatrix(); |
60 | void setupBackgroundColor(); | |
86
4bec0525ef1b
PolygonObjectEditor can now modify the object properly
Teemu Piippo <teemu@hecknology.net>
parents:
73
diff
changeset
|
61 | Q_SLOT void build(); |
31
b6df269a2c6b
fix remaining rendering control issues
Teemu Piippo <teemu@hecknology.net>
parents:
30
diff
changeset
|
62 | double zoom = 1.0; |
22
6da867fa5429
commit work on GL rendering
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
63 | bool initialized = false; |
86
4bec0525ef1b
PolygonObjectEditor can now modify the object properly
Teemu Piippo <teemu@hecknology.net>
parents:
73
diff
changeset
|
64 | bool needBuild = true; |
26 | 65 | void renderVao(const gl::ArrayClass arrayClass); |
66 | void checkForGLErrors(); | |
17 | 67 | }; |