Tue, 28 Sep 2021 00:10:29 +0300
Saving works now
#pragma once #include <QOpenGLWidget> #include <QOpenGLFunctions> #include <QQuaternion> #include <QOpenGLVertexArrayObject> #include <QOpenGLBuffer> #include <QOpenGLShader> #include <QOpenGLShaderProgram> #include <glm/glm.hpp> #include "main.h" #include "gl/common.h" #include "gl/compiler.h" class PartRenderer : public QOpenGLWidget, protected QOpenGLFunctions { Q_OBJECT public: PartRenderer( Model* model, DocumentManager* documents, const ldraw::ColorTable& colorTable, QWidget* parent = nullptr); ~PartRenderer() override; void setRenderPreferences(const gl::RenderPreferences& newPreferences); ldraw::id_t getHighlightedObject() const; protected: ldraw::id_t pick(const QPoint& where); void initializeGL() override; void resizeGL(int width, int height) override; void paintGL() override; void mouseMoveEvent(QMouseEvent* event) override; void wheelEvent(QWheelEvent* event) override; Model* const model; DocumentManager* const documents; const ldraw::ColorTable& colorTable; gl::Compiler* const compiler; ldraw::id_t highlighted = ldraw::NULL_ID; std::optional<glm::vec3> screenToModelCoordinates(const QPoint& point, const geom::Plane& plane) const; QPointF modelToScreenCoordinates(const glm::vec3& point) const; geom::Line<3> cameraLine(const QPoint& point) const; glm::vec3 unproject(const glm::vec3& win) const; glm::mat4 projectionMatrix; glm::mat4 viewMatrix; glm::mat4 modelMatrix; glm::vec4 viewportVector; glm::quat modelQuaternion; QPoint lastMousePosition; gl::RenderPreferences renderPreferences; Q_SIGNALS: void projectionMatrixChanged(const glm::mat4& newMatrix); void modelMatrixChanged(const glm::mat4& newMatrix); void viewMatrixChanged(const glm::mat4& newMatrix); void renderPreferencesChanged(); private: void setFragmentStyle(gl::FragmentStyle fragStyle); void renderAllArrays(); void renderScene(); void updateViewMatrix(); void updateModelMatrix(); void setupBackgroundColor(); Q_SLOT void build(); double zoom = 1.0; bool initialized = false; bool needBuild = true; void renderVao(const gl::ArrayClass arrayClass); void checkForGLErrors(); };