diff -r cef43609a374 -r 0133e565e072 src/gl/compiler.h --- a/src/gl/compiler.h Sat Dec 14 23:00:01 2019 +0200 +++ b/src/gl/compiler.h Wed Jan 01 17:45:56 2020 +0200 @@ -18,44 +18,45 @@ #pragma once #include "main.h" -#include "gl/partrenderer.h" #include "gl/common.h" #include "types/boundingbox.h" #include #include +class Model; +class DocumentManager; + namespace gl { class Compiler; class Renderer; + struct VboAddress + { + VboClass vboClass; + VboSubclass vboSubclass; + }; + int vboIndex(const VboAddress vboAddress); } -/* - * Compiles LDObjects into polygons for the GLRenderer to draw. - */ class gl::Compiler : public QObject, protected QOpenGLFunctions { Q_OBJECT public: - Compiler(Renderer* renderer); + Compiler(QObject* parent); ~Compiler(); - void initialize(); - Point3D modelCenter(); - void prepareVBO (int vbonum); - GLuint vbo (int vbonum) const; - int vboSize (int vbonum) const; - static int vboNumber (VboClass surface, VboSubclass complement); + void build(Model* model, DocumentManager* context); + void buildPolygon(Polygon polygon, std::vector* vboData); + void upload(const int vboIndex, const std::vector& data); + GLuint vbo(const VboAddress vboAddress) const; + int vboSize(const VboAddress vboAddress) const; + QColor getColorForPolygon(const gl::Polygon& polygon, VboSubclass subclass); + void writeColor(std::vector* data, const gl::Polygon& polygon, VboSubclass subclass); private: - struct ObjectVboData - { - QVector data[gl::numVbos]; - }; - QMap m_objectInfo; - QSet m_staged; // Objects that need to be compiled - GLuint m_vbo[gl::numVbos]; + void initializeVbo(); + GLuint storedVbo[gl::numVbos]; bool m_vboChanged[gl::numVbos] = {true}; - bool needBoundingBoxRebuild = true; - int m_vboSizes[gl::numVbos] = {0}; + int storedVboSizes[gl::numVbos] = {0}; + bool initialized = false; }; #define CHECK_GL_ERROR() { checkGLError(__FILE__, __LINE__); }