From 0dd2554101e0ef5d703c89eb671066e56f56c1f4 Mon Sep 17 00:00:00 2001 From: Fredrik Orderud Date: Sun, 6 Sep 2015 21:50:59 +0200 Subject: Fix broken openglax by introducing QOpenGLFunctions_1_1. The openglax example relies on deprecated OpenGL 1.1 functions that are no longer present in OpenGL ES 2. This leads to a missing symbols linker error. The problem is fixed by inheriting from QOpenGLFunctions_1_1 that provides implementations of the missing OpenGL functions. The GLBox destructor is also hardened with selective delete to avoid crashing if initializeGL is not called (occurs when dumping IDL). Change-Id: If35539749ab76293f98a5d75944f0f393f4d2a3c Reviewed-by: Friedemann Kleint --- examples/activeqt/activeqt.pro | 2 +- examples/activeqt/opengl/glbox.cpp | 6 +++++- examples/activeqt/opengl/glbox.h | 2 ++ examples/activeqt/opengl/main.cpp | 4 ++-- 4 files changed, 10 insertions(+), 4 deletions(-) (limited to 'examples') diff --git a/examples/activeqt/activeqt.pro b/examples/activeqt/activeqt.pro index 1fe8bee..dcfdb81 100644 --- a/examples/activeqt/activeqt.pro +++ b/examples/activeqt/activeqt.pro @@ -7,7 +7,7 @@ SUBDIRS += comapp \ wrapper contains(QT_CONFIG, shared):SUBDIRS += webbrowser -contains(QT_CONFIG, opengl):!contains(QT_CONFIG, opengles2):!contains(QT_CONFIG, dynamicgl): SUBDIRS += opengl +contains(QT_CONFIG, opengl):!contains(QT_CONFIG, opengles2): SUBDIRS += opengl # For now only the contain examples with mingw, for the others you need # an IDL compiler diff --git a/examples/activeqt/opengl/glbox.cpp b/examples/activeqt/opengl/glbox.cpp index 3f2b5bb..04c854c 100644 --- a/examples/activeqt/opengl/glbox.cpp +++ b/examples/activeqt/opengl/glbox.cpp @@ -78,7 +78,9 @@ GLBox::GLBox( QWidget* parent, const char* name ) GLBox::~GLBox() { makeCurrent(); - glDeleteLists( object, 1 ); + + if (object) + glDeleteLists( object, 1 ); } @@ -109,6 +111,8 @@ void GLBox::paintGL() void GLBox::initializeGL() { + initializeOpenGLFunctions(); + qglClearColor(Qt::black); // Let OpenGL clear to black object = makeObject(); // Generate an OpenGL display list glShadeModel( GL_FLAT ); diff --git a/examples/activeqt/opengl/glbox.h b/examples/activeqt/opengl/glbox.h index 53e3487..eb68c39 100644 --- a/examples/activeqt/opengl/glbox.h +++ b/examples/activeqt/opengl/glbox.h @@ -48,10 +48,12 @@ #define GLBOX_H #include +#include //! [0] #include class GLBox : public QGLWidget, + public QOpenGLFunctions_1_1, public QAxBindable { Q_OBJECT diff --git a/examples/activeqt/opengl/main.cpp b/examples/activeqt/opengl/main.cpp index 861bf4e..0596b2b 100644 --- a/examples/activeqt/opengl/main.cpp +++ b/examples/activeqt/opengl/main.cpp @@ -72,8 +72,8 @@ int main( int argc, char **argv ) QApplication::setColorSpec( QApplication::CustomColor ); QApplication a(argc,argv); - if ( !QGLFormat::hasOpenGL() ) { - qWarning( "This system has no OpenGL support. Exiting." ); + if (QOpenGLContext::openGLModuleType() != QOpenGLContext::LibGL) { + qWarning( "This system does not support OpenGL. Exiting." ); return -1; } -- cgit v1.2.3