src/gl/partrenderer.cpp

changeset 86
4bec0525ef1b
parent 78
97c3ce5aa498
child 92
c438a7db7c52
equal deleted inserted replaced
85:40e2940605a3 86:4bec0525ef1b
59 if (glGetError() != GL_NO_ERROR) 59 if (glGetError() != GL_NO_ERROR)
60 { 60 {
61 abort(); 61 abort();
62 } 62 }
63 this->compiler->initialize(); 63 this->compiler->initialize();
64 this->compiler->build(this->model, this->documents, this->renderPreferences); 64 connect(this->model, &Model::dataChanged, this, &PartRenderer::build);
65 connect(this->model, &Model::dataChanged, [&]()
66 {
67 this->compiler->build(this->model, this->documents, this->renderPreferences);
68 });
69 this->initialized = true; 65 this->initialized = true;
70 this->modelQuaternion = glm::angleAxis(glm::radians(30.0f), glm::vec3{-1, 0, 0}); 66 this->modelQuaternion = glm::angleAxis(glm::radians(30.0f), glm::vec3{-1, 0, 0});
71 this->modelQuaternion *= glm::angleAxis(glm::radians(225.0f), glm::vec3{-0, 1, 0}); 67 this->modelQuaternion *= glm::angleAxis(glm::radians(225.0f), glm::vec3{-0, 1, 0});
72 this->setupBackgroundColor(); 68 this->setupBackgroundColor();
73 this->updateModelMatrix(); 69 this->updateModelMatrix();
110 this->renderScene(); 106 this->renderScene();
111 } 107 }
112 108
113 void PartRenderer::renderScene() 109 void PartRenderer::renderScene()
114 { 110 {
111 if (this->needBuild)
112 {
113 this->compiler->build(this->model, this->documents, this->renderPreferences);
114 this->needBuild = false;
115 }
115 this->checkForGLErrors(); 116 this->checkForGLErrors();
116 if (this->renderPreferences.lineAntiAliasing && this->renderPreferences.style != gl::RenderStyle::PickScene) 117 if (this->renderPreferences.lineAntiAliasing && this->renderPreferences.style != gl::RenderStyle::PickScene)
117 { 118 {
118 glEnable(GL_LINE_SMOOTH); 119 glEnable(GL_LINE_SMOOTH);
119 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); 120 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
210 211
211 void PartRenderer::setupBackgroundColor() 212 void PartRenderer::setupBackgroundColor()
212 { 213 {
213 } 214 }
214 215
216 void PartRenderer::build()
217 {
218 this->needBuild = true;
219 }
220
215 void PartRenderer::renderVao(const gl::ArrayClass arrayClass) 221 void PartRenderer::renderVao(const gl::ArrayClass arrayClass)
216 { 222 {
217 this->compiler->bindVertexArray(arrayClass); 223 this->compiler->bindVertexArray(arrayClass);
218 const std::size_t vertexCount = this->compiler->vertexCount(arrayClass); 224 const std::size_t vertexCount = this->compiler->vertexCount(arrayClass);
219 this->checkForGLErrors(); 225 this->checkForGLErrors();
368 bool mainColorChanged = this->renderPreferences.mainColor != newPreferences.mainColor; 374 bool mainColorChanged = this->renderPreferences.mainColor != newPreferences.mainColor;
369 bool backgroundColorChanged = this->renderPreferences.backgroundColor != newPreferences.backgroundColor; 375 bool backgroundColorChanged = this->renderPreferences.backgroundColor != newPreferences.backgroundColor;
370 this->renderPreferences = newPreferences; 376 this->renderPreferences = newPreferences;
371 if (mainColorChanged or backgroundColorChanged) 377 if (mainColorChanged or backgroundColorChanged)
372 { 378 {
373 this->compiler->build(this->model, this->documents, this->renderPreferences); 379 this->build();
374 this->setupBackgroundColor(); 380 this->setupBackgroundColor();
375 } 381 }
376 emit this->renderPreferencesChanged(); 382 emit this->renderPreferencesChanged();
377 this->update(); 383 this->update();
378 } 384 }

mercurial