Commit 52465b70 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 e45cf4db
......@@ -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;
......
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