From 7d4bf1868d298a0bdc3f83ada6befb9ba4389cf5 Mon Sep 17 00:00:00 2001 From: Berthold Krevert Date: Wed, 4 Feb 2015 10:18:36 +0100 Subject: Use correct QOpenGLFunctions object If core profile is used, QOpenGLContext::versionFunctions returns 0 if a legacy or a non-core profile version is requested. That means, when using core profile we have to request a QOpenGLFunctions_3_2_Core object (which is the lowest OpenGL version that comes with profiles). Otherwise the application would run into a segfault. Change-Id: I8119e5fbeafccf14d59680617172c71e60e188ce Reviewed-by: Laszlo Agocs --- src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp') diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index 688a5fcb44..bd91841b1c 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include "qsgmaterialshader_p.h" @@ -2411,9 +2412,20 @@ void Renderer::renderUnmergedBatch(const Batch *batch) glLineWidth(g->lineWidth()); #if !defined(QT_OPENGL_ES_2) else if (!QOpenGLContext::currentContext()->isOpenGLES() && g->drawingMode() == GL_POINTS) { - QOpenGLFunctions_1_0 *gl1funcs = QOpenGLContext::currentContext()->versionFunctions(); - gl1funcs->initializeOpenGLFunctions(); - gl1funcs->glPointSize(g->lineWidth()); + QOpenGLFunctions_1_0 *gl1funcs = 0; + QOpenGLFunctions_3_2_Core *gl3funcs = 0; + if (QOpenGLContext::currentContext()->format().profile() == QSurfaceFormat::CoreProfile) { + gl3funcs = QOpenGLContext::currentContext()->versionFunctions(); + gl3funcs->initializeOpenGLFunctions(); + } else { + gl1funcs = QOpenGLContext::currentContext()->versionFunctions(); + gl1funcs->initializeOpenGLFunctions(); + } + Q_ASSERT(gl1funcs || gl3funcs); + if (gl1funcs) + gl1funcs->glPointSize(g->lineWidth()); + else + gl3funcs->glPointSize(g->lineWidth()); } #endif -- cgit v1.2.3