Sun, 26 Jan 2020 01:06:27 +0200
fix default angle
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: |
26 | 18 | PartRenderer(Model* model, DocumentManager* documents, const ColorTable& colorTable, QWidget* parent = nullptr); |
19 | ~PartRenderer() override; | |
17 | 20 | protected: |
21 | void initializeGL() override; | |
22 | void resizeGL(int width, int height) override; | |
23 | void paintGL() override; | |
24 | void mouseMoveEvent(QMouseEvent* event) override; | |
31
b6df269a2c6b
fix remaining rendering control issues
Teemu Piippo <teemu@hecknology.net>
parents:
30
diff
changeset
|
25 | void wheelEvent(QWheelEvent* event) override; |
18 | 26 | private slots: |
27 | void setRenderStyle(const gl::RenderStyle newStyle); | |
17 | 28 | private: |
22
6da867fa5429
commit work on GL rendering
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
29 | void renderScene(); |
31
b6df269a2c6b
fix remaining rendering control issues
Teemu Piippo <teemu@hecknology.net>
parents:
30
diff
changeset
|
30 | void updateViewMatrix(); |
21 | 31 | Model* const model; |
32 | DocumentManager* const documents; | |
26 | 33 | const ColorTable& colorTable; |
17 | 34 | QPointF lastMousePosition; |
22
6da867fa5429
commit work on GL rendering
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
35 | gl::Compiler* compiler; |
18 | 36 | gl::RenderStyle renderStyle = gl::RenderStyle::Normal; |
28 | 37 | glm::mat4 projectionMatrix; |
38 | glm::mat4 viewMatrix; | |
31
b6df269a2c6b
fix remaining rendering control issues
Teemu Piippo <teemu@hecknology.net>
parents:
30
diff
changeset
|
39 | glm::quat modelQuaternion; |
b6df269a2c6b
fix remaining rendering control issues
Teemu Piippo <teemu@hecknology.net>
parents:
30
diff
changeset
|
40 | static constexpr double MIN_ZOOM = 0.0; |
b6df269a2c6b
fix remaining rendering control issues
Teemu Piippo <teemu@hecknology.net>
parents:
30
diff
changeset
|
41 | static constexpr double MAX_ZOOM = 3.0; |
b6df269a2c6b
fix remaining rendering control issues
Teemu Piippo <teemu@hecknology.net>
parents:
30
diff
changeset
|
42 | double zoom = 1.0; |
22
6da867fa5429
commit work on GL rendering
Teemu Piippo <teemu@hecknology.net>
parents:
21
diff
changeset
|
43 | bool initialized = false; |
17 | 44 | void initializeLighting(); |
26 | 45 | void renderVao(const gl::ArrayClass arrayClass); |
46 | void checkForGLErrors(); | |
31
b6df269a2c6b
fix remaining rendering control issues
Teemu Piippo <teemu@hecknology.net>
parents:
30
diff
changeset
|
47 | glm::mat4 modelMatrix() const; |
17 | 48 | }; |