Skip to content

Commit a46ac23

Browse files
wonder-sknyalldawson
authored andcommittedNov 10, 2018
[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. (cherry picked from commit 4505929)
1 parent 4d2b2ba commit a46ac23

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
 

‎src/3d/qgsoffscreen3dengine.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,28 @@
3232
#include <Qt3DRender/QRenderSurfaceSelector>
3333
#include <Qt3DRender/QTexture>
3434
#include <Qt3DRender/QViewport>
35+
#include <QtGui/QOpenGLContext>
3536

3637

3738
QgsOffscreen3DEngine::QgsOffscreen3DEngine()
3839
{
3940
// Set up the default OpenGL surface format.
4041
QSurfaceFormat format;
42+
43+
// by default we get just some older version of OpenGL from the system,
44+
// but for 3D lines we use "primitive restart" functionality supported in OpenGL >= 3.1
45+
// Qt3DWindow uses this - requesting OpenGL 4.3 - so let's request the same version.
46+
#ifdef QT_OPENGL_ES_2
47+
format.setRenderableType( QSurfaceFormat::OpenGLES );
48+
#else
49+
if ( QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL )
50+
{
51+
format.setVersion( 4, 3 );
52+
format.setProfile( QSurfaceFormat::CoreProfile );
53+
}
54+
#endif
55+
56+
format.setMajorVersion( 3 );
4157
format.setDepthBufferSize( 32 ); // TODO: or 24? (used by QWindow3D)
4258
format.setSamples( 8 );
4359
QSurfaceFormat::setDefaultFormat( format );

0 commit comments

Comments
 (0)
Please sign in to comment.