25 #include <QAbstractButton> |
25 #include <QAbstractButton> |
26 #include "geometry.h" |
26 #include "geometry.h" |
27 #include "partrenderer.h" |
27 #include "partrenderer.h" |
28 #include "model.h" |
28 #include "model.h" |
29 #include "gl/compiler.h" |
29 #include "gl/compiler.h" |
|
30 #include "gl/debug.h" |
|
31 #include "settings.h" |
30 |
32 |
31 static constexpr double MIN_ZOOM = -3.0; |
33 static constexpr double MIN_ZOOM = -3.0; |
32 static constexpr double MAX_ZOOM = 3.0; |
34 static constexpr double MAX_ZOOM = 3.0; |
33 QOpenGLFunctions glfunc; |
35 QOpenGLFunctions glfunc; |
34 |
36 |
45 this->setMouseTracking(true); |
47 this->setMouseTracking(true); |
46 this->setFocusPolicy(Qt::WheelFocus); |
48 this->setFocusPolicy(Qt::WheelFocus); |
47 QSurfaceFormat surfaceFormat; |
49 QSurfaceFormat surfaceFormat; |
48 surfaceFormat.setSamples(8); |
50 surfaceFormat.setSamples(8); |
49 this->setFormat(surfaceFormat); |
51 this->setFormat(surfaceFormat); |
|
52 connect(&this->logger, &QOpenGLDebugLogger::messageLogged, [&](const QOpenGLDebugMessage& glmessage){ |
|
53 Q_EMIT this->message(debugMessageToString(glmessage)); |
|
54 }); |
50 connect(model, &Model::rowsInserted, [&]{ |
55 connect(model, &Model::rowsInserted, [&]{ |
51 this->needBuild = true; |
56 this->needBuild = true; |
52 }); |
57 }); |
53 connect(model, &Model::rowsRemoved, [&]{ this->needBuild = true; }); |
58 connect(model, &Model::rowsRemoved, [&]{ this->needBuild = true; }); |
54 const auto updateLayerMvpMatrix = [this]{ |
59 const auto updateLayerMvpMatrix = [this]{ |
89 for (RenderLayer* layer : this->activeRenderLayers) { |
94 for (RenderLayer* layer : this->activeRenderLayers) { |
90 layer->initializeGL(); |
95 layer->initializeGL(); |
91 } |
96 } |
92 for (RenderLayer* layer : this->inactiveRenderLayers) { |
97 for (RenderLayer* layer : this->inactiveRenderLayers) { |
93 layer->initializeGL(); |
98 layer->initializeGL(); |
|
99 } |
|
100 this->logger.initialize(); |
|
101 if (setting<Setting::LogOpenGLDebugMessages>()) { |
|
102 this->logger.startLogging(); |
94 } |
103 } |
95 connect(this->model, &Model::dataChanged, this, &PartRenderer::build); |
104 connect(this->model, &Model::dataChanged, this, &PartRenderer::build); |
96 this->initialized = true; |
105 this->initialized = true; |
97 this->modelQuaternion = glm::angleAxis(glm::radians(30.0f), glm::vec3{-1, 0, 0}); |
106 this->modelQuaternion = glm::angleAxis(glm::radians(30.0f), glm::vec3{-1, 0, 0}); |
98 this->modelQuaternion *= glm::angleAxis(glm::radians(225.0f), glm::vec3{-0, 1, 0}); |
107 this->modelQuaternion *= glm::angleAxis(glm::radians(225.0f), glm::vec3{-0, 1, 0}); |
482 this->renderPreferences = newPreferences; |
491 this->renderPreferences = newPreferences; |
483 if (mainColorChanged or backgroundColorChanged) |
492 if (mainColorChanged or backgroundColorChanged) |
484 { |
493 { |
485 this->build(); |
494 this->build(); |
486 } |
495 } |
|
496 if (this->initialized) { |
|
497 this->makeCurrent(); |
|
498 if (setting<Setting::LogOpenGLDebugMessages>()) { |
|
499 this->logger.startLogging(); |
|
500 } |
|
501 else { |
|
502 this->logger.stopLogging(); |
|
503 } |
|
504 } |
487 Q_EMIT this->renderPreferencesChanged(); |
505 Q_EMIT this->renderPreferencesChanged(); |
488 this->update(); |
506 this->update(); |
489 } |
507 } |
490 |
508 |
491 /** |
509 /** |