Skip to content

Commit

Permalink
Make sure OpenGL core profile context is used by GzScene3D
Browse files Browse the repository at this point in the history
Should fix gazebosim/gz-rendering#128 .

Signed-off-by: Martin Pecka <peci1@seznam.cz>
  • Loading branch information
peci1 committed Sep 9, 2020
1 parent 5c151bf commit 687a274
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/gui/plugins/scene3d/Scene3D.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1922,8 +1922,18 @@ QSGNode *RenderWindowItem::updatePaintNode(QSGNode *_node,
// and makeCurrent down below while setting up our own context.
current->doneCurrent();

auto surfaceFormat = QSurfaceFormat();
surfaceFormat.setMajorVersion(3);
surfaceFormat.setMinorVersion(3);
surfaceFormat.setProfile(QSurfaceFormat::CoreProfile);

this->dataPtr->renderThread->context = new QOpenGLContext();
this->dataPtr->renderThread->context->setFormat(current->format());
// Although it seems unbelievable, we can request another format for a
// shared context; it is needed because Qt selects by default a compat
// context which is much less likely to provide OpenGL 3.3 (only closed
// NVidia drivers). This means there will be mismatch between what is
// reported by QSG_INFO=1 and by OGRE.
this->dataPtr->renderThread->context->setFormat(surfaceFormat);
this->dataPtr->renderThread->context->setShareContext(current);
this->dataPtr->renderThread->context->create();
this->dataPtr->renderThread->context->moveToThread(
Expand Down

0 comments on commit 687a274

Please sign in to comment.