Qt5OpenGL: make off-screen renderer working

This commit is contained in:
wmayer
2017-03-12 18:22:36 +01:00
parent 67f05c98fa
commit 34f277e7bb
6 changed files with 59 additions and 14 deletions

View File

@@ -136,7 +136,14 @@ void Thumbnail::createThumbnailFromFramebuffer(QImage& img) const
// Alternative way of off-screen rendering
if (this->viewer->isActiveWindow()) {
static_cast<QtGLWidget*>(this->viewer->getGLWidget())->makeCurrent();
QtGLFramebufferObject fbo(this->size, this->size,QtGLFramebufferObject::Depth);
#if defined(HAVE_QT5_OPENGL)
QtGLFramebufferObjectFormat format;
format.setAttachment(QtGLFramebufferObject::Depth);
format.setInternalTextureFormat(GL_RGB32F_ARB);
QtGLFramebufferObject fbo(this->size, this->size, format);
#else
QtGLFramebufferObject fbo(this->size, this->size, QtGLFramebufferObject::Depth);
#endif
this->viewer->renderToFramebuffer(&fbo);
img = fbo.toImage();
static_cast<QtGLWidget*>(this->viewer->getGLWidget())->doneCurrent();