src/gl/partrenderer.cpp

changeset 259
c27612f0eac0
parent 250
2837b549e616
child 264
76a025db4948
--- a/src/gl/partrenderer.cpp	Wed Jun 22 23:51:06 2022 +0300
+++ b/src/gl/partrenderer.cpp	Sun Jun 26 19:44:45 2022 +0300
@@ -33,7 +33,12 @@
 
 static constexpr double MIN_ZOOM = -3.0;
 static constexpr double MAX_ZOOM = 3.0;
-QOpenGLFunctions glfunc;
+
+QOpenGLFunctions& glfunc()
+{
+	static QOpenGLFunctions funcs;
+	return funcs;
+}
 
 PartRenderer::PartRenderer(
 	Model* model,
@@ -87,11 +92,7 @@
 
 void PartRenderer::initializeGL()
 {
-	::glfunc.initializeOpenGLFunctions();
-	if (glGetError() != GL_NO_ERROR)
-	{
-		abort();
-	}
+	glfunc().initializeOpenGLFunctions();
 	gl::initializeModelShaders(&this->shaders);
 	for (RenderLayer* layer : this->activeRenderLayers) {
 		layer->initializeGL();
@@ -468,7 +469,7 @@
 	this->renderScene();
 	std::array<GLubyte, 3> data;
 	this->checkForGLErrors();
-	glfunc.glReadPixels(where.x(), where.y(), 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &data[0]);
+	glReadPixels(where.x(), where.y(), 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &data[0]);
 	this->checkForGLErrors();
 	fbo.release();
 	this->renderPreferences.style = oldRenderStyle;

mercurial