Commit d37aacbc authored by Jan Möbius's avatar Jan Möbius

Implemented capabilities check for renderer interface.

Todo: set the correct requirements for the renderer plugins

refs #995

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@15664 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 8dfd8683
......@@ -88,6 +88,40 @@ class RenderInterface {
*/
virtual QString rendererName() = 0;
/** \brief Check OpenGL capabilities
*
* This function has to be implemented and checks, if all required OpenGL extensions are available.
* If this is not the case, the plugin will be refused by the core to avoid crashes due to insufficient
* OpenGL support.
*
* You can get the version information in the following way:
*
* \code
*
* // Get version and check
* QGLFormat::OpenGLVersionFlags flags = QGLFormat::openGLVersionFlags();
* if ( ! flags.testFlag(QGLFormat::OpenGL_Version_2_1) )
* return QString("Insufficient OpenGL Version! OpenGL 2.1 or higher required");
*
* //Get OpenGL extensions
* QString glExtensions = QString((const char*)glGetString(GL_EXTENSIONS));
*
* // Collect missing extension
* QString missing = "";
*
* if ( !glExtensions.contains("GL_ARB_vertex_buffer_object") )
* missing += "Missing Extension GL_ARB_vertex_buffer_object\n";
*
* if ( !glExtensions.contains("GL_ARB_vertex_program") )
* missing += "Missing Extension GL_ARB_vertex_program\n";
*
* return missing;
* \endcode
*
* @return Return an empty string if everything is fine, otherwise return, what features are missing.
*/
virtual QString checkOpenGL() = 0;
public slots:
/** \brief rendering function
......@@ -110,6 +144,8 @@ class RenderInterface {
*/
virtual QAction* optionsAction() { return 0; };
};
/** \page renderInterfacePage Render Interface
......
......@@ -1912,6 +1912,15 @@ void Core::loadPlugin(QString filename, bool silent, QString& _licenseErrors, QO
// Get the name of the renderer
QMetaObject::invokeMethod(plugin,"rendererName", Qt::DirectConnection, Q_RETURN_ARG(QString,rendererNameString) ) ;
// Let the plugin check its OpenGL support requirements
QString openGLCheck = "";
QMetaObject::invokeMethod(plugin,"checkOpenGL", Qt::DirectConnection, Q_RETURN_ARG(QString,openGLCheck) ) ;
if ( openGLCheck != "" ) {
emit log(LOGERR,tr("Error: Insufficient OpenGL capabilities!"));
emit log(LOGERR,openGLCheck);
}
// Check if it already exists and add it if not.
RendererInfo* rendererInfo = 0;
if ( ! renderManager().rendererExists(rendererNameString) ) {
......@@ -1920,6 +1929,9 @@ void Core::loadPlugin(QString filename, bool silent, QString& _licenseErrors, QO
emit log(LOGERR,tr("Error: Renderer Plugin %1 already exists").arg(rendererNameString));
}
// Retrieve and store renderer information
if ( rendererInfo != 0) {
rendererInfo->plugin = renderPlugin;
......
......@@ -44,6 +44,8 @@
#include <OpenFlipper/common/GlobalOptions.hh>
#include <ObjectTypes/Light/LightNode.hh>
#include <QGLFormat>
// this define enables a shader export of the generated peel shader for debugging purpose
//#define DEPTHPEELING_SHADER_EXPORT
......@@ -1510,5 +1512,30 @@ void DepthPeelingPlugin::render(ACG::GLState* _glState, Viewer::ViewerProperties
glPopAttrib();
}
QString DepthPeelingPlugin::checkOpenGL() {
// TODO: Correctly configure the following requirements!
// Get version and check
QGLFormat::OpenGLVersionFlags flags = QGLFormat::openGLVersionFlags();
if ( ! flags.testFlag(QGLFormat::OpenGL_Version_2_0) )
return QString("Insufficient OpenGL Version! OpenGL 2.0 or higher required");
//Get OpenGL extensions
QString glExtensions = QString((const char*)glGetString(GL_EXTENSIONS));
// Collect missing extension
QString missing = "";
// if ( !glExtensions.contains("GL_ARB_vertex_buffer_object") )
// missing += "Missing Extension GL_ARB_vertex_buffer_object\n";
//
// if ( !glExtensions.contains("GL_ARB_vertex_program") )
// missing += "Missing Extension GL_ARB_vertex_program\n";
return missing;
}
Q_EXPORT_PLUGIN2( depthpeelingplugin , DepthPeelingPlugin );
......@@ -86,6 +86,7 @@ private slots:
void render(ACG::GLState* _glState, Viewer::ViewerProperties& _properties);
QString rendererName();
void supportedDrawModes(ACG::SceneGraph::DrawModes::DrawMode& _mode);
QString checkOpenGL();
private:
......
......@@ -50,6 +50,8 @@
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <OpenFlipper/common/GlobalOptions.hh>
#include <QGLFormat>
void RenderPickingPlugin::initializePlugin()
{
pickRendererMode_ = ACG::SceneGraph::PICK_ANYTHING;
......@@ -163,5 +165,24 @@ void RenderPickingPlugin::render(ACG::GLState* _glState, Viewer::ViewerPropertie
}
QString RenderPickingPlugin::checkOpenGL() {
// TODO: Correctly configure the following requirements!
// Get version and check
QGLFormat::OpenGLVersionFlags flags = QGLFormat::openGLVersionFlags();
if ( ! flags.testFlag(QGLFormat::OpenGL_Version_2_0) )
return QString("Insufficient OpenGL Version! OpenGL 2.0 or higher required");
//Get OpenGL extensions
QString glExtensions = QString((const char*)glGetString(GL_EXTENSIONS));
// Collect missing extension
QString missing = "";
return missing;
}
Q_EXPORT_PLUGIN2( renderpickingplugin , RenderPickingPlugin );
......@@ -77,6 +77,7 @@ class RenderPickingPlugin : public QObject, BaseInterface, RenderInterface
void render(ACG::GLState* _glState, Viewer::ViewerProperties& _properties);
QString rendererName();
void supportedDrawModes(ACG::SceneGraph::DrawModes::DrawMode& _mode);
QString checkOpenGL();
// The picking target has been changed
......
......@@ -45,6 +45,8 @@
#include <OpenFlipper/common/GlobalOptions.hh>
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <QGLFormat>
// shader debug mode triggers a shader reload after resizing the view window
//#define SSAO_SHADER_DEBUG_MODE
......@@ -707,5 +709,30 @@ void SSAOPlugin::render(ACG::GLState* _glState, Viewer::ViewerProperties& _prope
glPopAttrib();
}
QString SSAOPlugin::checkOpenGL() {
// TODO: Correctly configure the following requirements!
// Get version and check
QGLFormat::OpenGLVersionFlags flags = QGLFormat::openGLVersionFlags();
if ( ! flags.testFlag(QGLFormat::OpenGL_Version_2_0) )
return QString("Insufficient OpenGL Version! OpenGL 2.0 or higher required");
//Get OpenGL extensions
QString glExtensions = QString((const char*)glGetString(GL_EXTENSIONS));
// Collect missing extension
QString missing = "";
// if ( !glExtensions.contains("GL_ARB_vertex_buffer_object") )
// missing += "Missing Extension GL_ARB_vertex_buffer_object\n";
//
// if ( !glExtensions.contains("GL_ARB_vertex_program") )
// missing += "Missing Extension GL_ARB_vertex_program\n";
return missing;
}
Q_EXPORT_PLUGIN2( ssaoplugin , SSAOPlugin );
......@@ -85,6 +85,7 @@ private slots:
void render(ACG::GLState* _glState, Viewer::ViewerProperties& _properties);
QString rendererName();
void supportedDrawModes(ACG::SceneGraph::DrawModes::DrawMode& _mode);
QString checkOpenGL();
private:
......
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