src/gl/partrenderer.cpp

changeset 259
c27612f0eac0
parent 250
2837b549e616
child 264
76a025db4948
equal deleted inserted replaced
258:fe094d0687ad 259:c27612f0eac0
31 #include "gl/debug.h" 31 #include "gl/debug.h"
32 #include "settings.h" 32 #include "settings.h"
33 33
34 static constexpr double MIN_ZOOM = -3.0; 34 static constexpr double MIN_ZOOM = -3.0;
35 static constexpr double MAX_ZOOM = 3.0; 35 static constexpr double MAX_ZOOM = 3.0;
36 QOpenGLFunctions glfunc; 36
37 QOpenGLFunctions& glfunc()
38 {
39 static QOpenGLFunctions funcs;
40 return funcs;
41 }
37 42
38 PartRenderer::PartRenderer( 43 PartRenderer::PartRenderer(
39 Model* model, 44 Model* model,
40 DocumentManager* documents, 45 DocumentManager* documents,
41 const ColorTable& colorTable, 46 const ColorTable& colorTable,
85 }; 90 };
86 } 91 }
87 92
88 void PartRenderer::initializeGL() 93 void PartRenderer::initializeGL()
89 { 94 {
90 ::glfunc.initializeOpenGLFunctions(); 95 glfunc().initializeOpenGLFunctions();
91 if (glGetError() != GL_NO_ERROR)
92 {
93 abort();
94 }
95 gl::initializeModelShaders(&this->shaders); 96 gl::initializeModelShaders(&this->shaders);
96 for (RenderLayer* layer : this->activeRenderLayers) { 97 for (RenderLayer* layer : this->activeRenderLayers) {
97 layer->initializeGL(); 98 layer->initializeGL();
98 } 99 }
99 for (RenderLayer* layer : this->inactiveRenderLayers) { 100 for (RenderLayer* layer : this->inactiveRenderLayers) {
466 QOpenGLFramebufferObject fbo{this->width(), this->height(), QOpenGLFramebufferObject::CombinedDepthStencil}; 467 QOpenGLFramebufferObject fbo{this->width(), this->height(), QOpenGLFramebufferObject::CombinedDepthStencil};
467 fbo.bind(); 468 fbo.bind();
468 this->renderScene(); 469 this->renderScene();
469 std::array<GLubyte, 3> data; 470 std::array<GLubyte, 3> data;
470 this->checkForGLErrors(); 471 this->checkForGLErrors();
471 glfunc.glReadPixels(where.x(), where.y(), 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &data[0]); 472 glReadPixels(where.x(), where.y(), 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &data[0]);
472 this->checkForGLErrors(); 473 this->checkForGLErrors();
473 fbo.release(); 474 fbo.release();
474 this->renderPreferences.style = oldRenderStyle; 475 this->renderPreferences.style = oldRenderStyle;
475 return gl::idFromColor(data); 476 return gl::idFromColor(data);
476 } 477 }

mercurial