src/gl/partrenderer.cpp

changeset 238
b8ad4c12d937
parent 237
10a6298f636f
child 246
86a35ce38773
--- a/src/gl/partrenderer.cpp	Mon Jun 20 19:49:56 2022 +0300
+++ b/src/gl/partrenderer.cpp	Mon Jun 20 21:14:17 2022 +0300
@@ -18,6 +18,7 @@
 
 #include <glm/ext/matrix_transform.hpp>
 #include <glm/ext/matrix_clip_space.hpp>
+#include <QOpenGLFramebufferObject>
 #include <QPainter>
 #include <GL/glu.h>
 #include <QMouseEvent>
@@ -461,13 +462,15 @@
 	const gl::RenderStyle oldRenderStyle = this->renderPreferences.style;
 	this->renderPreferences.style = gl::RenderStyle::PickScene;
 	this->makeCurrent();
+	QOpenGLFramebufferObject fbo{this->width(), this->height(), QOpenGLFramebufferObject::CombinedDepthStencil};
+	fbo.bind();
 	this->renderScene();
 	std::array<GLubyte, 3> data;
 	this->checkForGLErrors();
 	glfunc.glReadPixels(where.x(), where.y(), 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &data[0]);
 	this->checkForGLErrors();
+	fbo.release();
 	this->renderPreferences.style = oldRenderStyle;
-	this->update();
 	return gl::idFromColor(data);
 }
 

mercurial