src/gl/compiler.h

changeset 51
1a9eac27698d
parent 50
0f80a2e5e42b
child 73
97df974b5ed5
equal deleted inserted replaced
50:0f80a2e5e42b 51:1a9eac27698d
39 { 39 {
40 glm::vec3 position; 40 glm::vec3 position;
41 glm::vec4 color; 41 glm::vec4 color;
42 glm::vec3 normal; 42 glm::vec3 normal;
43 glm::int32 id; 43 glm::int32 id;
44 glm::int32 selected = 0;
44 }; 45 };
45 } 46 }
46 47
47 class gl::Compiler : public QObject, protected QOpenGLExtraFunctions 48 class gl::Compiler : public QObject, protected QOpenGLExtraFunctions
48 { 49 {
53 void build(Model* model, DocumentManager* context, const RenderPreferences& preferences); 54 void build(Model* model, DocumentManager* context, const RenderPreferences& preferences);
54 void buildPolygon(Polygon polygon, std::vector<Vertex>* vboData, const gl::RenderPreferences& preferences); 55 void buildPolygon(Polygon polygon, std::vector<Vertex>* vboData, const gl::RenderPreferences& preferences);
55 std::size_t vertexCount(gl::ArrayClass arrayClass) const; 56 std::size_t vertexCount(gl::ArrayClass arrayClass) const;
56 QColor getColorForPolygon(const gl::Polygon& polygon, const RenderPreferences& preferences); 57 QColor getColorForPolygon(const gl::Polygon& polygon, const RenderPreferences& preferences);
57 glm::vec3 modelCenter() const; 58 glm::vec3 modelCenter() const;
58 float modelDistance() const; 59 double modelDistance() const;
59 void initialize(); 60 void initialize();
60 void bindVertexArray(gl::ArrayClass arrayClass); 61 void bindVertexArray(gl::ArrayClass arrayClass);
61 void releaseVertexArray(gl::ArrayClass arrayClass); 62 void releaseVertexArray(gl::ArrayClass arrayClass);
62 void buildShaders(int arrayId); 63 void buildShaders(int arrayId);
64 void setSelectedObjects(const QSet<ldraw::Id> ids);
63 65
64 static ldraw::Id idFromColor(const std::array<GLbyte, 3>& data); 66 static ldraw::Id idFromColor(const std::array<GLbyte, 3>& data);
65 67
66 template<typename T> 68 template<typename T>
67 void setUniform(const char* uniformName, T&& value) 69 void setUniform(const char* uniformName, T&& value)
93 { 95 {
94 QOpenGLShaderProgram* program = nullptr; 96 QOpenGLShaderProgram* program = nullptr;
95 QOpenGLShaderProgram* pickSceneProgram = nullptr; 97 QOpenGLShaderProgram* pickSceneProgram = nullptr;
96 QOpenGLBuffer buffer{QOpenGLBuffer::VertexBuffer}; 98 QOpenGLBuffer buffer{QOpenGLBuffer::VertexBuffer};
97 QOpenGLVertexArrayObject vertexArray; 99 QOpenGLVertexArrayObject vertexArray;
100 std::vector<gl::Vertex> cachedData;
98 } glObjects[gl::NUM_ARRAY_CLASSES]; 101 } glObjects[gl::NUM_ARRAY_CLASSES];
99 }; 102 };
100 103
101 #define CHECK_GL_ERROR() { checkGLError(__FILE__, __LINE__); } 104 #define CHECK_GL_ERROR() { checkGLError(__FILE__, __LINE__); }
102 void checkGLError (QString file, int line); 105 void checkGLError (QString file, int line);

mercurial