Commit b0d19e3c authored by Jan Möbius's avatar Jan Möbius
Browse files

Implement Qt5 style to detect current OpenGL Context capability

Don't use classical rendering plugin if no compatibility context is available


git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@21124 383ad7c9-94d9-4d36-a494-682f7c89f535
parent a1fb8739
......@@ -55,8 +55,15 @@
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <ACG/GL/ShaderCache.hh>
#undef QT_NO_OPENGL
#include <QGLFormat>
#if QT_VERSION >= 0x050000
#include <QOpenGLContext>
#include <QSurfaceFormat>
#else
#undef QT_NO_OPENGL
#include <QGLFormat>
#endif
#include <QMenu>
......@@ -98,23 +105,54 @@ void Renderer::render(ACG::GLState* _glState, Viewer::ViewerProperties& _propert
QString Renderer::checkOpenGL()
{
// Get version and check
QGLFormat::OpenGLVersionFlags flags = QGLFormat::openGLVersionFlags();
if ( !flags.testFlag(QGLFormat::OpenGL_Version_3_2) )
return QString("Insufficient OpenGL Version! OpenGL 3.2 or higher required");
// Check extensions
QString glExtensions = QString((const char*)glGetString(GL_EXTENSIONS));
QString missing("");
if ( !glExtensions.contains("GL_ARB_vertex_buffer_object") )
missing += "GL_ARB_vertex_buffer_object extension missing\n";
#ifndef __APPLE__
if ( !glExtensions.contains("GL_ARB_vertex_program") )
missing += "GL_ARB_vertex_program extension missing\n";
#endif
#if QT_VERSION < 0x050000
// Get version and check
QGLFormat::OpenGLVersionFlags flags = QGLFormat::openGLVersionFlags();
if ( !flags.testFlag(QGLFormat::OpenGL_Version_3_2) )
return QString("Insufficient OpenGL Version! OpenGL 3.2 or higher required");
// Check extensions
QString glExtensions = QString((const char*)glGetString(GL_EXTENSIONS));
QString missing("");
if ( !glExtensions.contains("GL_ARB_vertex_buffer_object") )
missing += "GL_ARB_vertex_buffer_object extension missing\n";
#ifndef __APPLE__
if ( !glExtensions.contains("GL_ARB_vertex_program") )
missing += "GL_ARB_vertex_program extension missing\n";
#endif
return missing;
#else
QOpenGLContext* context = QOpenGLContext::currentContext();
if ( context ) {
// Get version and check
QSurfaceFormat format = context->format();
if ( (format.majorVersion() < 4) && (format.minorVersion() < 2) ) {
return QString("Insufficient OpenGL Version! OpenGL 3.2 or higher required");
}
// Check extensions
QString missing("");
if ( !context->hasExtension("GL_ARB_vertex_buffer_object") )
missing += "GL_ARB_vertex_buffer_object extension missing\n";
#ifndef __APPLE__
if ( !context->hasExtension("GL_ARB_vertex_program") )
missing += "GL_ARB_vertex_program extension missing\n";
#endif
return missing;
} else {
return name() + QString(": No context available");
}
#endif
return missing;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment