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

Integrated renderer interface

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@12304 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 5d620ad1
...@@ -68,15 +68,7 @@ class RenderInterface { ...@@ -68,15 +68,7 @@ class RenderInterface {
private slots: private slots:
/** \brief rendering function
*
* Implement this function to render the scene. You have to traverse the
* scenegraph in this function. The glContext is made current before this
* call.
* If you need to initialize something,you can do it within this function.
* gl and glew are already setUp here.
*/
virtual void render(/* Unknow options yet.. to be evaluated*/) {};
/** \brief announce required draw modes /** \brief announce required draw modes
* *
...@@ -88,7 +80,7 @@ class RenderInterface { ...@@ -88,7 +80,7 @@ class RenderInterface {
* *
* @param _mode Combined list of drawmodes * @param _mode Combined list of drawmodes
*/ */
virtual void supportedDrawModes(ACG::SceneGraph::DrawModes::DrawMode& _mode) {}; virtual void supportedDrawModes(ACG::SceneGraph::DrawModes::DrawMode& _mode) = 0;
/** \brief announce name for the rendering function /** \brief announce name for the rendering function
* *
...@@ -97,17 +89,17 @@ class RenderInterface { ...@@ -97,17 +89,17 @@ class RenderInterface {
*/ */
virtual QString rendererName() = 0; virtual QString rendererName() = 0;
signals: public slots:
/** \brief register a new rendering function to the core /** \brief rendering function
*
* Emit this signal to register your plugin with a given drawmode.
* Whenever this drawmode is active OpenFlipper will not call its internal
* rendering but your plugins render function.
* *
* @param _mode The drawmode for the new rendering function * Implement this function to render the scene. You have to traverse the
* scenegraph in this function. The glContext is made current before this
* call.
* If you need to initialize something,you can do it within this function.
* gl and glew are already setUp here.
*/ */
virtual void registerRenderingFunction(ACG::SceneGraph::DrawModes::DrawMode _mode) {}; virtual void render(ACG::GLState* _glState) {};
}; };
......
...@@ -1888,8 +1888,6 @@ void Core::loadPlugin(QString filename, bool silent, QString& _licenseErrors, QO ...@@ -1888,8 +1888,6 @@ void Core::loadPlugin(QString filename, bool silent, QString& _licenseErrors, QO
// Get the name of the renderer // Get the name of the renderer
QMetaObject::invokeMethod(plugin,"rendererName", Qt::DirectConnection, Q_RETURN_ARG(QString,rendererNameString) ) ; 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. // Check if it already exists and add it if not.
RendererInfo* rendererInfo = 0; RendererInfo* rendererInfo = 0;
if ( ! renderManager().rendererExists(rendererNameString) ) { if ( ! renderManager().rendererExists(rendererNameString) ) {
...@@ -1900,8 +1898,7 @@ void Core::loadPlugin(QString filename, bool silent, QString& _licenseErrors, QO ...@@ -1900,8 +1898,7 @@ void Core::loadPlugin(QString filename, bool silent, QString& _licenseErrors, QO
// Retrieve and store renderer information // Retrieve and store renderer information
if ( rendererInfo != 0) { if ( rendererInfo != 0) {
std::cerr << "Rendererinfo ok" << std::endl; rendererInfo->plugin = renderPlugin;
rendererInfo->plugin = plugin;
ACG::SceneGraph::DrawModes::DrawMode supportedModes; ACG::SceneGraph::DrawModes::DrawMode supportedModes;
...@@ -1929,8 +1926,6 @@ void Core::loadPlugin(QString filename, bool silent, QString& _licenseErrors, QO ...@@ -1929,8 +1926,6 @@ void Core::loadPlugin(QString filename, bool silent, QString& _licenseErrors, QO
// Get the name of the PostProcessor // Get the name of the PostProcessor
QMetaObject::invokeMethod(plugin,"postProcessorName", Qt::DirectConnection, Q_RETURN_ARG(QString,postProcessorNameString) ) ; QMetaObject::invokeMethod(plugin,"postProcessorName", Qt::DirectConnection, Q_RETURN_ARG(QString,postProcessorNameString) ) ;
std::cerr << postProcessorNameString.toStdString() << std::endl;
// Check if it already exists and add it if not. // Check if it already exists and add it if not.
PostProcessorInfo* postProcessorInfo = 0; PostProcessorInfo* postProcessorInfo = 0;
if ( ! postProcessorManager().postProcessorExists(postProcessorNameString) ) { if ( ! postProcessorManager().postProcessorExists(postProcessorNameString) ) {
...@@ -1941,7 +1936,6 @@ void Core::loadPlugin(QString filename, bool silent, QString& _licenseErrors, QO ...@@ -1941,7 +1936,6 @@ void Core::loadPlugin(QString filename, bool silent, QString& _licenseErrors, QO
// Retrieve and store PostProcessor information // Retrieve and store PostProcessor information
if ( postProcessorInfo != 0) { if ( postProcessorInfo != 0) {
std::cerr << "PostProcessor ok" << std::endl;
postProcessorInfo->plugin = postProcessorPlugin; postProcessorInfo->plugin = postProcessorPlugin;
} }
......
...@@ -61,7 +61,7 @@ RendererInfo::RendererInfo(): ...@@ -61,7 +61,7 @@ RendererInfo::RendererInfo():
{ {
} }
RendererInfo::RendererInfo(QObject* _plugin,QString _name) : RendererInfo::RendererInfo(RenderInterface* _plugin,QString _name) :
plugin(_plugin), plugin(_plugin),
name(_name) name(_name)
{ {
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include <QObject> #include <QObject>
#include <ACG/Scenegraph/DrawModes.hh> #include <ACG/Scenegraph/DrawModes.hh>
#include <OpenFlipper/BasePlugin/PostProcessorInterface.hh> #include <OpenFlipper/BasePlugin/PostProcessorInterface.hh>
#include <OpenFlipper/BasePlugin/RenderInterface.hh>
#include <vector> #include <vector>
...@@ -58,10 +59,10 @@ class RendererInfo{ ...@@ -58,10 +59,10 @@ class RendererInfo{
RendererInfo(); RendererInfo();
RendererInfo(QObject* _plugin,QString _name); RendererInfo(RenderInterface* _plugin,QString _name);
/// Pointer to the loaded plugin (Already casted when loading it) /// Pointer to the loaded plugin (Already casted when loading it)
QObject* plugin; RenderInterface* plugin;
/// Name of the plugin ( requested from the plugin on load) /// Name of the plugin ( requested from the plugin on load)
QString name; QString name;
......
...@@ -212,6 +212,42 @@ void CoreWidget::updatePopupMenuCoordsysNode(QMenu* _menu , const int /*_part*/ ...@@ -212,6 +212,42 @@ void CoreWidget::updatePopupMenuCoordsysNode(QMenu* _menu , const int /*_part*/
mipmapping->setChecked( PluginFunctions::viewerProperties().mipmapping() ); mipmapping->setChecked( PluginFunctions::viewerProperties().mipmapping() );
connect(mipmapping, SIGNAL(triggered(bool)), this , SLOT( slotLocalChangeMipmapping(bool) ) ); connect(mipmapping, SIGNAL(triggered(bool)), this , SLOT( slotLocalChangeMipmapping(bool) ) );
//============================================================================================================
// Renderer Menu
//============================================================================================================
if ( renderManager().available() > 1 ) {
QMenu* rendererMenu = new QMenu(tr("Renderers"),_menu);
_menu->addMenu(rendererMenu);
// Recreate actionGroup
QActionGroup* groupRenderer = new QActionGroup( this );
groupRenderer->setExclusive( true );
for ( unsigned int i = 0 ; i < renderManager().available() ; ++i) {
// Add a new Action with the renderer name
QAction * action = new QAction( renderManager()[i]->name, groupRenderer );
action->setCheckable( true );
// Check if this processor is currently active
if ( renderManager().activeId(PluginFunctions::activeExaminer() ) == i )
action->setChecked(true);
// Remember the id for the processor
action->setData(QVariant(i));
}
// Add all new actions from the group to the menu
rendererMenu->addActions( groupRenderer->actions() );
// Connect signal of group to our managing slot
connect( groupRenderer , SIGNAL( triggered( QAction * ) ),
this , SLOT( slotRenderMenu( QAction * ) ) );
}
//============================================================================================================ //============================================================================================================
// Post processor Menu // Post processor Menu
//============================================================================================================ //============================================================================================================
...@@ -855,4 +891,9 @@ void CoreWidget::slotPostProcessorMenu( QAction * _action) { ...@@ -855,4 +891,9 @@ void CoreWidget::slotPostProcessorMenu( QAction * _action) {
postProcessorManager().setActive(mode,PluginFunctions::activeExaminer()); postProcessorManager().setActive(mode,PluginFunctions::activeExaminer());
} }
void CoreWidget::slotRenderMenu( QAction * _action) {
unsigned int mode = _action->data().toUInt();
renderManager().setActive(mode,PluginFunctions::activeExaminer());
}
//============================================================================= //=============================================================================
...@@ -848,6 +848,9 @@ public: ...@@ -848,6 +848,9 @@ public:
/// Called when a different post processor has been chosen /// Called when a different post processor has been chosen
void slotPostProcessorMenu( QAction * _action); void slotPostProcessorMenu( QAction * _action);
/// Called when a different renderer has been chosen
void slotRenderMenu( QAction * _action);
/// Creates a draw Menu for the currently active Viewer /// Creates a draw Menu for the currently active Viewer
void slotUpdateViewerDrawMenu(); void slotUpdateViewerDrawMenu();
......
...@@ -597,8 +597,14 @@ void glViewer::drawScene() ...@@ -597,8 +597,14 @@ void glViewer::drawScene()
std::cerr << "Active postprocessor: " << postProcessorManager().active()->name.toStdString() << std::endl; std::cerr << "Active postprocessor: " << postProcessorManager().active()->name.toStdString() << std::endl;
*/ */
// Check if we use build in default renderers
if ( renderManager().activeId( properties_.viewerId() ) == 0 ) {
if (stereo_) drawScene_stereo(); if (stereo_) drawScene_stereo();
else drawScene_mono(); else drawScene_mono();
} else {
renderManager().active( properties_.viewerId() )->plugin->render(glstate_);
}
if ( postProcessorManager().activeId( properties_.viewerId() ) != 0 ) { if ( postProcessorManager().activeId( properties_.viewerId() ) != 0 ) {
......
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