Commit b84ae56e authored by Hans-Christian Ebke's avatar Hans-Christian Ebke
Browse files

Offer additional enter and leave methods.

The additional enter and leave methods have an IRenderer* parameter
that allow the implementation of additional functionality in nodes
for modern renderers implementing the IRenderer interface.
parent d1538be2
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
#include <iostream> #include <iostream>
#include <algorithm>
#include <QFile> #include <QFile>
#include <QTextStream> #include <QTextStream>
...@@ -436,7 +437,7 @@ void IRenderer::traverseRenderableNodes( ACG::GLState* _glState, ACG::SceneGraph ...@@ -436,7 +437,7 @@ void IRenderer::traverseRenderableNodes( ACG::GLState* _glState, ACG::SceneGraph
{ {
if ( _node->status() != ACG::SceneGraph::BaseNode::HideNode ) if ( _node->status() != ACG::SceneGraph::BaseNode::HideNode )
_node->enter(*_glState, nodeDM); _node->enter(this, *_glState, nodeDM);
// fetch material (Node itself can be a material node, so we have to // fetch material (Node itself can be a material node, so we have to
...@@ -468,7 +469,7 @@ void IRenderer::traverseRenderableNodes( ACG::GLState* _glState, ACG::SceneGraph ...@@ -468,7 +469,7 @@ void IRenderer::traverseRenderableNodes( ACG::GLState* _glState, ACG::SceneGraph
if (_node->status() != ACG::SceneGraph::BaseNode::HideNode ) if (_node->status() != ACG::SceneGraph::BaseNode::HideNode )
_node->leave(*_glState, nodeDM); _node->leave(this, *_glState, nodeDM);
} }
} }
} }
......
...@@ -176,11 +176,40 @@ public: ...@@ -176,11 +176,40 @@ public:
/** This function is called when traversing the scene graph and /** This function is called when traversing the scene graph and
arriving at this node. It can be used to store GL states that arriving at this node. It can be used to store GL states that
will be changed in order to restore then in the leave() will be changed in order to restore then in the leave()
function. function.
There are two overloads of the enter() function, one with IRenderer*
parameter, the other one without. As long the overload with IRenderer*
parameter is not being overridden, all renderers will make use of the
overload without the IRenderer* parameter. If the overload with IRenderer*
parameter is being overridden, only legacy renderers will use the version
without the additional parameter and new renderers implementing the
IRenderer interface will use the version with the additional parameter.
\see MaterialNode \see MaterialNode
*/ */
virtual void enter(GLState& /*_state */, const DrawModes::DrawMode& /*_drawMode*/ ) {} virtual void enter(GLState& /*_state */, const DrawModes::DrawMode& /*_drawMode*/ ) {}
/** This function is called when traversing the scene graph and
arriving at this node. It can be used to store GL states that
will be changed in order to restore then in the leave()
function.
If you do not need the IRenderer* argument in your override of this
function, simply use the override without the additional parameter.
There are two overloads of the enter() function, one with IRenderer*
parameter, the other one without. As long the overload with IRenderer*
parameter is not being overridden, all renderers will make use of the
overload without the IRenderer* parameter. If the overload with IRenderer*
parameter is being overridden, only legacy renderers will use the version
without the additional parameter and new renderers implementing the
IRenderer interface will use the version with the additional parameter.
*/
virtual void enter(IRenderer* /*_renderer*/, GLState& _state, const DrawModes::DrawMode& _drawMode) {
enter(_state, _drawMode);
}
/** \brief Draw this node using the draw modes _drawMode /** \brief Draw this node using the draw modes _drawMode
* *
* This function is called when the scenegraph is traversed by the classical draw routines. * This function is called when the scenegraph is traversed by the classical draw routines.
...@@ -212,10 +241,36 @@ public: ...@@ -212,10 +241,36 @@ public:
virtual void getRenderObjects(IRenderer* _renderer, GLState& _state , const DrawModes::DrawMode& _drawMode , const Material* _mat) {} virtual void getRenderObjects(IRenderer* _renderer, GLState& _state , const DrawModes::DrawMode& _drawMode , const Material* _mat) {}
/** The leave function is used to restore GL states the have been changed. /** The leave function is used to restore GL states the have been changed.
This function must restore the status before enter() ! This function must restore the status before enter()!
There are two overloads of the leave() function, one with IRenderer*
parameter, the other one without. As long the overload with IRenderer*
parameter is not being overridden, all renderers will make use of the
overload without the IRenderer* parameter. If the overload with IRenderer*
parameter is being overridden, only legacy renderers will use the version
without the additional parameter and new renderers implementing the
IRenderer interface will use the version with the additional parameter.
*/ */
virtual void leave(GLState& /* _state */, const DrawModes::DrawMode& /* _drawMode */) {} virtual void leave(GLState& /* _state */, const DrawModes::DrawMode& /* _drawMode */) {}
/** The leave function is used to restore GL states the have been changed.
This function must restore the status before enter()!
If you do not need the IRenderer* argument in your override of this
function, simply use the override without the additional parameter.
There are two overloads of the leave() function, one with IRenderer*
parameter, the other one without. As long the overload with IRenderer*
parameter is not being overridden, all renderers will make use of the
overload without the IRenderer* parameter. If the overload with IRenderer*
parameter is being overridden, only legacy renderers will use the version
without the additional parameter and new renderers implementing the
IRenderer interface will use the version with the additional parameter.
*/
virtual void leave(IRenderer* /*_renderer*/, GLState& _state, const DrawModes::DrawMode& _drawMode) {
leave(_state, _drawMode);
}
/** This function is called when traversing the scene graph during picking /** This function is called when traversing the scene graph during picking
and arriving at this node. It can be used to store GL states that and arriving at this node. It can be used to store GL states that
will be changed in order to restore then in the leavePick() will be changed in order to restore then in the leavePick()
......
Supports Markdown
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