Commit 0d31fe08 authored by Jan Möbius's avatar Jan Möbius

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 a8dea2b4
......@@ -47,8 +47,6 @@
* *
\*===========================================================================*/
#include <ACG/GL/acg_glew.hh>
#include "PostProcessorAnaglyphPlugin.hh"
#include <iostream>
......@@ -60,6 +58,14 @@
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <OpenFlipper/common/GlobalOptions.hh>
#if QT_VERSION >= 0x050000
#include <QOpenGLContext>
#include <QSurfaceFormat>
#else
#include <QGLFormat>
#endif
PostProcessorAnaglyphPlugin::PostProcessorAnaglyphPlugin()
{
}
......@@ -69,10 +75,41 @@ PostProcessorAnaglyphPlugin::~PostProcessorAnaglyphPlugin()
}
QString PostProcessorAnaglyphPlugin::checkOpenGL() {
if ( ! ACG::openGLVersion(3, 0) )
#if QT_VERSION < 0x050000
QGLFormat::OpenGLVersionFlags flags = QGLFormat::openGLVersionFlags();
if ( ! flags.testFlag(QGLFormat::OpenGL_Version_3_0) )
return QString("Insufficient OpenGL Version! OpenGL 3.0 or higher required");
return QString("");
// Check extensions
QString glExtensions = QString((const char*)glGetString(GL_EXTENSIONS));
QString missing("");
return missing;
#else
QOpenGLContext* context = QOpenGLContext::currentContext();
if ( context ) {
// Get version and check
QSurfaceFormat format = context->format();
if ( (format.majorVersion() < 3) ) {
return QString("Insufficient OpenGL Version! OpenGL 3.0 or higher required");
}
// Check extensions
QString missing("");
return missing;
} else {
return name() + QString(": No context available");
}
#endif
}
......
......@@ -54,12 +54,49 @@
*/
#include "PostProcessorDepthImagePlugin.hh"
#include <QGLFormat>
#if QT_VERSION >= 0x050000
#include <QOpenGLContext>
#include <QSurfaceFormat>
#else
#include <QGLFormat>
#endif
QString PostProcessorDepthImagePlugin::checkOpenGL() {
#if QT_VERSION < 0x050000
QGLFormat::OpenGLVersionFlags flags = QGLFormat::openGLVersionFlags();
if ( ! flags.testFlag(QGLFormat::OpenGL_Version_3_0) )
return QString("Insufficient OpenGL Version! OpenGL 3.0 or higher required");
return QString("");
// Check extensions
QString glExtensions = QString((const char*)glGetString(GL_EXTENSIONS));
QString missing("");
return missing;
#else
QOpenGLContext* context = QOpenGLContext::currentContext();
if ( context ) {
// Get version and check
QSurfaceFormat format = context->format();
if ( (format.majorVersion() < 3) ) {
return QString("Insufficient OpenGL Version! OpenGL 3.0 or higher required");
}
// Check extensions
QString missing("");
return missing;
} else {
return name() + QString(": No context available");
}
#endif
}
......@@ -55,12 +55,48 @@
#include "PostProcessorGrayPlugin.hh"
#include <QGLFormat>
#if QT_VERSION >= 0x050000
#include <QOpenGLContext>
#include <QSurfaceFormat>
#else
#include <QGLFormat>
#endif
QString PostProcessorGrayscalePlugin::checkOpenGL() {
#if QT_VERSION < 0x050000
QGLFormat::OpenGLVersionFlags flags = QGLFormat::openGLVersionFlags();
if ( ! flags.testFlag(QGLFormat::OpenGL_Version_3_0) )
return QString("Insufficient OpenGL Version! OpenGL 3.0 or higher required");
return QString("");
// Check extensions
QString glExtensions = QString((const char*)glGetString(GL_EXTENSIONS));
QString missing("");
return missing;
#else
QOpenGLContext* context = QOpenGLContext::currentContext();
if ( context ) {
// Get version and check
QSurfaceFormat format = context->format();
if ( (format.majorVersion() < 3) ) {
return QString("Insufficient OpenGL Version! OpenGL 3.0 or higher required");
}
// Check extensions
QString missing("");
return missing;
} else {
return name() + QString(": No context available");
}
#endif
}
......@@ -56,9 +56,21 @@
#include "PostProcessorPhilipsStereo.hh"
#include "widgets/philipsStereoSettingsWidget.hh"
#include <OpenFlipper/common/GlobalOptions.hh>
#include <QGLFormat>
#if QT_VERSION >= 0x050000
#include <QOpenGLContext>
#include <QSurfaceFormat>
#else
#include <QGLFormat>
#endif
QString PostProcessorPhilipsStereoPlugin::checkOpenGL() {
#if QT_VERSION < 0x050000
QGLFormat::OpenGLVersionFlags flags = QGLFormat::openGLVersionFlags();
if ( ! flags.testFlag(QGLFormat::OpenGL_Version_3_0) )
return QString("Insufficient OpenGL Version! OpenGL 3.0 or higher required");
......@@ -70,6 +82,35 @@ QString PostProcessorPhilipsStereoPlugin::checkOpenGL() {
missing += "GL_ARB_texture_rectangle extension missing\n";
return missing;
#else
QOpenGLContext* context = QOpenGLContext::currentContext();
if ( context ) {
// Get version and check
QSurfaceFormat format = context->format();
if ( (format.majorVersion() < 3) ) {
return QString("Insufficient OpenGL Version! OpenGL 3.0 or higher required");
}
// Check extensions
QString missing("");
if ( !context->hasExtension("GL_ARB_texture_rectangle") )
missing += "GL_ARB_vertex_buffer_object extension missing\n";
return missing;
} else {
return name() + QString(": No context available");
}
#endif
}
void PostProcessorPhilipsStereoPlugin::slotShowOptionsMenu() {
......
......@@ -55,12 +55,48 @@
#include "PostProcessorSobelPlugin.hh"
#include <QGLFormat>
#if QT_VERSION >= 0x050000
#include <QOpenGLContext>
#include <QSurfaceFormat>
#else
#include <QGLFormat>
#endif
QString PostProcessorSobelPlugin::checkOpenGL() {
#if QT_VERSION < 0x050000
QGLFormat::OpenGLVersionFlags flags = QGLFormat::openGLVersionFlags();
if ( ! flags.testFlag(QGLFormat::OpenGL_Version_3_0) )
return QString("Insufficient OpenGL Version! OpenGL 3.0 or higher required");
return QString("");
// Check extensions
QString glExtensions = QString((const char*)glGetString(GL_EXTENSIONS));
QString missing("");
return missing;
#else
QOpenGLContext* context = QOpenGLContext::currentContext();
if ( context ) {
// Get version and check
QSurfaceFormat format = context->format();
if ( (format.majorVersion() < 3) ) {
return QString("Insufficient OpenGL Version! OpenGL 3.0 or higher required");
}
// Check extensions
QString missing("");
return missing;
} else {
return name() + QString(": No context available");
}
#endif
}
......@@ -59,6 +59,8 @@
#include <OpenFlipper/common/ViewObjectMarker.hh>
#include <QGLFormat>
using namespace ACG;
// =================================================
......@@ -199,8 +201,13 @@ void Renderer::render(ACG::GLState* _glState, Viewer::ViewerProperties& _propert
QString Renderer::checkOpenGL()
{
// Get version and check
if ( QGLContext::currentContext()->format().profile() != QGLFormat::CompatibilityProfile )
return QString("This plugin requires an OpenGL compatibility context to work.");
// This renderer plugin should run on almost any old style hardware
return QString("");
}
......
......@@ -55,12 +55,22 @@
#include "DepthPeeling.hh"
#include <QGLFormat>
#include <QAction>
#include <QMenu>
#if QT_VERSION >= 0x050000
#include <QOpenGLContext>
#include <QSurfaceFormat>
#else
#include <QGLFormat>
#endif
QString DepthPeeling::checkOpenGL()
{
#if QT_VERSION < 0x050000
// Get version and check
QGLFormat::OpenGLVersionFlags flags = QGLFormat::openGLVersionFlags();
if ( !flags.testFlag(QGLFormat::OpenGL_Version_3_2) )
......@@ -72,15 +82,47 @@ QString DepthPeeling::checkOpenGL()
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
#ifndef __APPLE__
if ( !glExtensions.contains("GL_ARB_vertex_program") )
missing += "GL_ARB_vertex_program extension missing\n";
#endif
if ( !glExtensions.contains("GL_ARB_occlusion_query") )
missing += "GL_ARB_occlusion_query extension missing\n";
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
if ( !context->hasExtension("GL_ARB_occlusion_query") )
missing += "GL_ARB_occlusion_query extension missing\n";
return missing;
} else {
return name() + QString(": No context available");
}
#endif
}
QAction* DepthPeeling::optionsAction()
......
......@@ -52,7 +52,14 @@
#include <OpenFlipper/common/GlobalOptions.hh>
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <ACG/GL/ShaderCache.hh>
#include <QGLFormat>
#if QT_VERSION >= 0x050000
#include <QOpenGLContext>
#include <QSurfaceFormat>
#else
#include <QGLFormat>
#endif
// =================================================
......@@ -124,6 +131,11 @@ void NormalRenderer::render(ACG::GLState* _glState, Viewer::ViewerProperties& _p
QString NormalRenderer::checkOpenGL()
{
#if QT_VERSION < 0x050000
// Get version and check
QGLFormat::OpenGLVersionFlags flags = QGLFormat::openGLVersionFlags();
if ( !flags.testFlag(QGLFormat::OpenGL_Version_3_2) )
......@@ -135,12 +147,42 @@ QString NormalRenderer::checkOpenGL()
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
#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
}
#if QT_VERSION < 0x050000
......
......@@ -53,7 +53,13 @@
#include <ACG/GL/GLError.hh>
#include <QGLFormat>
#if QT_VERSION >= 0x050000
#include <QOpenGLContext>
#include <QSurfaceFormat>
#else
#include <QGLFormat>
#endif
// this define enables a shader export of the generated peel shader for debugging purpose
//#define DEPTHPEELING_SHADER_EXPORT
......@@ -1093,6 +1099,8 @@ unsigned int DepthPeelingPlugin::getPeelShaderIndex(ACG::SceneGraph::DrawModes::
QString DepthPeelingPlugin::checkOpenGL() {
#if QT_VERSION < 0x050000
// Get version and check
QGLFormat::OpenGLVersionFlags flags = QGLFormat::openGLVersionFlags();
if ( ! flags.testFlag(QGLFormat::OpenGL_Version_2_0) )
......@@ -1112,6 +1120,35 @@ QString DepthPeelingPlugin::checkOpenGL() {
return missing;
#else
QOpenGLContext* context = QOpenGLContext::currentContext();
if ( context ) {
// Get version and check
QSurfaceFormat format = context->format();
if ( (format.majorVersion() < 2) ) {
return QString("Insufficient OpenGL Version! OpenGL 2.0 or higher required");
}
// Check extensions
QString missing("");
if ( !context->hasExtension("GL_ARB_geometry_shader4") )
missing += "GL_ARB_geometry_shader4 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
}
......
......@@ -64,6 +64,14 @@
#include <QtGui>
#endif
#if QT_VERSION >= 0x050000
#include <QOpenGLContext>
#include <QSurfaceFormat>
#else
#include <QGLFormat>
#endif
void RenderPickingPlugin::initializePlugin()
{
pickRendererMode_ = ACG::SceneGraph::PICK_ANYTHING;
......@@ -177,7 +185,7 @@ void RenderPickingPlugin::render(ACG::GLState* _glState, Viewer::ViewerPropertie
QString RenderPickingPlugin::checkOpenGL() {
// TODO: Correctly configure the following requirements!
#if QT_VERSION < 0x050000
// Get version and check
QGLFormat::OpenGLVersionFlags flags = QGLFormat::openGLVersionFlags();
......@@ -192,6 +200,27 @@ QString RenderPickingPlugin::checkOpenGL() {
return missing;
#else
QOpenGLContext* context = QOpenGLContext::currentContext();
if ( context ) {
// Get version and check
QSurfaceFormat format = context->format();
if ( (format.majorVersion() < 2) ) {
return QString("Insufficient OpenGL Version! OpenGL 2.0 or higher required");
}
// Check extensions
QString missing("");
return missing;
} else {
return name() + QString(": No context available");
}
#endif
}
......
......@@ -54,32 +54,77 @@
*/
#include "SSAO.hh"
#include <QGLFormat>
#if QT_VERSION >= 0x050000
#include <QOpenGLContext>
#include <QSurfaceFormat>
#else
#include <QGLFormat>
#endif
QString SSAOPlugin::checkOpenGL() {
#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("");