Skip to content

Commit

Permalink
try setting up default surface format
Browse files Browse the repository at this point in the history
  • Loading branch information
NEDJIMAbelgacem authored and wonder-sk committed Mar 1, 2021
1 parent e70af6c commit b3f7a32
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/3d/qgsoffscreen3dengine.cpp
Expand Up @@ -38,6 +38,27 @@

QgsOffscreen3DEngine::QgsOffscreen3DEngine()
{
// Set up the default OpenGL surface format.
QSurfaceFormat format;

// by default we get just some older version of OpenGL from the system,
// but for 3D lines we use "primitive restart" functionality supported in OpenGL >= 3.1
// Qt3DWindow uses this - requesting OpenGL 4.3 - so let's request the same version.
qDebug() << "QOpenGLContext::openGLModuleType: " << QOpenGLContext::openGLModuleType();
#ifdef QT_OPENGL_ES_2
format.setRenderableType( QSurfaceFormat::OpenGLES );
#else
if ( QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL )
{
format.setVersion( 4, 3 );
format.setProfile( QSurfaceFormat::CoreProfile );
}
#endif

format.setMajorVersion( 3 );
format.setDepthBufferSize( 32 ); // TODO: or 24? (used by QWindow3D)
format.setSamples( 8 );
QSurfaceFormat::setDefaultFormat( format );

// Set up a camera to point at the shapes.
mCamera = new Qt3DRender::QCamera;
Expand Down Expand Up @@ -68,6 +89,7 @@ QgsOffscreen3DEngine::QgsOffscreen3DEngine()
// Create the offscreen frame graph, which will manage all of the resources required
// for rendering without a QWindow.
mOffscreenSurface = new QOffscreenSurface();
mOffscreenSurface->setFormat( QSurfaceFormat::defaultFormat() );
mOffscreenSurface->create();

mFrameGraph = new QgsShadowRenderingFrameGraph( mOffscreenSurface, mSize, mCamera, mRoot );
Expand Down

0 comments on commit b3f7a32

Please sign in to comment.