Commit 8d121a0c authored by Jan Möbius's avatar Jan Möbius

RenderManager and pluginloader integration for rendererinterface

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@12272 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 6563eea2
......@@ -78,14 +78,13 @@ class RenderInterface {
*/
virtual void render(/* Unknow options yet.. to be evaluated*/) {};
/** \brief announce required draw modes
*
* This function is called by the core to get a list of draw modes that are supported
* by this renderer. If such a draw mode is set and the currently active
* renderer does not support the given mode, the core will switch to
* this renderer automatically. If there are multiple renderers capable of rendering
* the drawmode, the core will ask the user for its preference.
* the drawmode(s), the core will ask the user for its preference.
*
* @param _mode Combined list of drawmodes
*/
......
......@@ -89,6 +89,8 @@
#include "OpenFlipper/BasePlugin/TypeInterface.hh"
#include "OpenFlipper/BasePlugin/PluginConnectionInterface.hh"
#include "OpenFlipper/Core/RendererInfo.hh"
#include "OpenFlipper/INIFile/INIFile.hh"
#include "OpenFlipper/common/GlobalOptions.hh"
......@@ -1882,10 +1884,34 @@ void Core::loadPlugin(QString filename, bool silent, QString& _licenseErrors, QO
if ( checkSlot( plugin , "rendererName()" ) ) {
QString rendererNameString = "";
// Get the name of the renderer
QMetaObject::invokeMethod(plugin,"rendererName", Qt::DirectConnection, Q_RETURN_ARG(QString,rendererNameString) ) ;
std::cerr << rendererNameString.toStdString() << std::endl;
// Check if it already exists and add it if not.
RendererInfo* rendererInfo = 0;
if ( ! renderManager().rendererExists(rendererNameString) ) {
rendererInfo = renderManager().newRenderer(rendererNameString);
} else {
emit log(LOGERR,tr("Error: Renderer Plugin %1 already exists").arg(rendererNameString));
}
// Retrieve and store renderer information
if ( rendererInfo != 0) {
std::cerr << "Rendererinfo ok" << std::endl;
rendererInfo->plugin = plugin;
ACG::SceneGraph::DrawModes::DrawMode supportedModes;
// Get the supported draw modes of the renderer
QMetaObject::invokeMethod(plugin,"supportedDrawModes", Q_ARG(ACG::SceneGraph::DrawModes::DrawMode& ,supportedModes) );
rendererInfo->modes = supportedModes;
}
} else {
emit log(LOGERR,tr("Error: Renderer Plugin without rendererNameFunction?!"));
}
std::cerr << "Render Plugin .. not yet implemented" << std::endl;
......
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
#include <OpenFlipper/Core/RendererInfo.hh>
#include <iostream>
static RenderManager renderManager_;
RenderManager& renderManager() {
return renderManager_;
}
RenderManager::RenderManager() {
availableRenderers_.clear();
std::cerr << "Render Manager Constructor" << std::endl;
}
bool RenderManager::rendererExists(QString _name) {
std::cerr << "Render Manager rendererExists ?" << std::endl;
for ( unsigned int i = 0 ; i < availableRenderers_.size() ; ++i)
if ( availableRenderers_[i].name == _name)
return true;
return false;
}
RendererInfo* RenderManager::newRenderer(QString _name) {
std::cerr << "Render Manager newRenderer" << std::endl;
for ( unsigned int i = 0 ; i < availableRenderers_.size() ; ++i)
if ( availableRenderers_[i].name == _name)
return &availableRenderers_[i];
availableRenderers_.push_back(RendererInfo());
availableRenderers_[availableRenderers_.size()-1].name = _name;
return &availableRenderers_[availableRenderers_.size()-1];
}
RendererInfo* RenderManager::getRenderer(QString _name) {
std::cerr << "Render Manager getRenderer" << std::endl;
for ( unsigned int i = 0 ; i < availableRenderers_.size() ; ++i)
if ( availableRenderers_[i].name == _name)
return &availableRenderers_[i];
return 0;
}
......@@ -46,6 +46,9 @@
#include <QString>
#include <QObject>
#include <ACG/Scenegraph/DrawModes.hh>
#include <vector>
/** Type defining a currently loaded Renderer */
class RendererInfo{
......@@ -62,6 +65,42 @@ class RendererInfo{
/// Name of the plugin ( requested from the plugin on load)
QString name;
/// Supported DrawModes
ACG::SceneGraph::DrawModes::DrawMode modes;
};
class RenderManager {
public:
RenderManager();
/** \brief Check if a renderer with the given name exists
*
* @param _name Name of the renderer
* @return exists or not
*/
bool rendererExists(QString _name);
/**\brief Get a new renderer Instance
*
* @param _name Name of the new renderer
*
* @return Pointer to renderer. If it exists, the existing one is returned!
*/
RendererInfo* newRenderer(QString _name);
/** \brief get renderer with the given name
*
* @param _name Name of the renderer
* @return pointer or 0 if it does not exist
*/
RendererInfo* getRenderer(QString _name);
private:
std::vector<RendererInfo> availableRenderers_;
};
/// Get an instance of the render manager
RenderManager& renderManager();
#endif //RENDERERINFO_HH
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