From 45059297e4a6e7729a14f09b1b553133cafa463f Mon Sep 17 00:00:00 2001 From: Martin Dobias Date: Tue, 6 Nov 2018 01:34:05 +0100 Subject: [PATCH] [3d] Fix 3D line symbol in 3D views in print layouts (fixes #20118) Turned out we were getting an old version of OpenGL that does not support the "primitive restart" functionality and so wherever a linestring should be broken it was connected through (0,0,0) to the next linestring. --- src/3d/qgsoffscreen3dengine.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/3d/qgsoffscreen3dengine.cpp b/src/3d/qgsoffscreen3dengine.cpp index 63cbd793232..ccf8d50b85b 100644 --- a/src/3d/qgsoffscreen3dengine.cpp +++ b/src/3d/qgsoffscreen3dengine.cpp @@ -32,12 +32,28 @@ #include #include #include +#include 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. +#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 );