From d5cc556bec24b35eea755fd7f1cb589f31600171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 17 Sep 2013 07:38:12 +0000 Subject: [PATCH] Added Postprocessor interface function to check OpenGL capabilities Return if Renderer or Postprocessor has insufficient OpenGL capabilities git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@17544 383ad7c9-94d9-4d36-a494-682f7c89f535 --- BasePlugin/PostProcessorInterface.hh | 36 ++++++++++++++++++++++++++++ Core/PluginLoader.cc | 16 +++++++++---- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/BasePlugin/PostProcessorInterface.hh b/BasePlugin/PostProcessorInterface.hh index a56fee66..f3d9d67a 100644 --- a/BasePlugin/PostProcessorInterface.hh +++ b/BasePlugin/PostProcessorInterface.hh @@ -106,6 +106,42 @@ class PostProcessorInterface { */ virtual QAction* optionsAction() { return 0; }; + private slots: + + /** \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; + }; /** \page postProcessorInterfacePage Post Processor Interface diff --git a/Core/PluginLoader.cc b/Core/PluginLoader.cc index e17111e4..9c23f19c 100644 --- a/Core/PluginLoader.cc +++ b/Core/PluginLoader.cc @@ -1975,8 +1975,9 @@ void Core::loadPlugin(const QString& _filename,const bool _silent, QString& _lic QMetaObject::invokeMethod(plugin,"checkOpenGL", Qt::DirectConnection, Q_RETURN_ARG(QString,openGLCheck) ) ; if ( openGLCheck != "" ) { - emit log(LOGERR,tr("Error: Insufficient OpenGL capabilities in Plugin") + rendererNameString + " !"); + emit log(LOGERR,tr("Error: Insufficient OpenGL capabilities in Renderer Plugin ") + rendererNameString + " !"); emit log(LOGERR,openGLCheck); + return; } // Check if it already exists and add it if not. @@ -1987,9 +1988,6 @@ void Core::loadPlugin(const QString& _filename,const bool _silent, QString& _lic emit log(LOGERR,tr("Error: Renderer Plugin %1 already exists").arg(rendererNameString)); } - - - // Retrieve and store renderer information if ( rendererInfo != 0) { rendererInfo->plugin = renderPlugin; @@ -2030,6 +2028,16 @@ void Core::loadPlugin(const QString& _filename,const bool _silent, QString& _lic // Get the name of the PostProcessor QMetaObject::invokeMethod(plugin,"postProcessorName", Qt::DirectConnection, Q_RETURN_ARG(QString,postProcessorNameString) ) ; + // 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 in post processor Plugin ") + postProcessorNameString + " !"); + emit log(LOGERR,openGLCheck); + return; + } + // Check if it already exists and add it if not. PostProcessorInfo* postProcessorInfo = 0; if ( ! postProcessorManager().postProcessorExists(postProcessorNameString) ) { -- GitLab