src/gl/partrenderer.h

changeset 57
5c0005f63319
parent 56
fad4a5dd8dee
child 58
b7841cd31fb7
equal deleted inserted replaced
56:fad4a5dd8dee 57:5c0005f63319
22 const ldraw::ColorTable& colorTable, 22 const ldraw::ColorTable& colorTable,
23 QWidget* parent = nullptr); 23 QWidget* parent = nullptr);
24 ~PartRenderer() override; 24 ~PartRenderer() override;
25 void setRenderPreferences(const gl::RenderPreferences& newPreferences); 25 void setRenderPreferences(const gl::RenderPreferences& newPreferences);
26 static glm::vec3 viewport(const glm::vec3& point, float width, float height); 26 static glm::vec3 viewport(const glm::vec3& point, float width, float height);
27 static glm::vec3 antiviewport(const glm::vec3& point, float width, float height);
27 protected: 28 protected:
28 ldraw::Id pick(const QPoint& where); 29 ldraw::Id pick(const QPoint& where);
29 void initializeGL() override; 30 void initializeGL() override;
30 void resizeGL(int width, int height) override; 31 void resizeGL(int width, int height) override;
31 void paintGL() override; 32 void paintGL() override;
37 const ldraw::ColorTable& colorTable; 38 const ldraw::ColorTable& colorTable;
38 gl::Compiler* const compiler; 39 gl::Compiler* const compiler;
39 ldraw::Id highlighted = ldraw::NULL_ID; 40 ldraw::Id highlighted = ldraw::NULL_ID;
40 std::optional<glm::vec3> screenToModelCoordinates(const QPoint& point); 41 std::optional<glm::vec3> screenToModelCoordinates(const QPoint& point);
41 QPointF modelToScreenCoordinates(const glm::vec3& point); 42 QPointF modelToScreenCoordinates(const glm::vec3& point);
43 glm::vec3 unproject(const glm::vec3& win);
42 private: 44 private:
43 void setFragmentStyle(gl::FragmentStyle fragStyle); 45 void setFragmentStyle(gl::FragmentStyle fragStyle);
44 void renderAllArrays(); 46 void renderAllArrays();
45 void renderScene(); 47 void renderScene();
46 void updateViewMatrix(); 48 void updateViewMatrix();
48 void setupBackgroundColor(); 50 void setupBackgroundColor();
49 QPointF lastMousePosition; 51 QPointF lastMousePosition;
50 gl::RenderPreferences renderPreferences; 52 gl::RenderPreferences renderPreferences;
51 glm::mat4 projectionMatrix; 53 glm::mat4 projectionMatrix;
52 glm::mat4 viewMatrix; 54 glm::mat4 viewMatrix;
55 glm::vec4 viewportVector;
53 glm::quat modelQuaternion; 56 glm::quat modelQuaternion;
54 std::optional<GridProgram> gridProgram; 57 std::optional<GridProgram> gridProgram;
55 static constexpr double MIN_ZOOM = 0.0; 58 static constexpr double MIN_ZOOM = 0.0;
56 static constexpr double MAX_ZOOM = 3.0; 59 static constexpr double MAX_ZOOM = 3.0;
57 double zoom = 1.0; 60 double zoom = 1.0;

mercurial