Commit b363c885 authored by Jan Möbius's avatar Jan Möbius
Browse files

Dennis: Added stencil reference node

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6625 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 1d0c147a
//=============================================================================
//
// OpenFlipper
// Copyright (C) 2009 by Computer Graphics Group, RWTH Aachen
// www.openflipper.org
//
//-----------------------------------------------------------------------------
//
// License
//
// 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.
//
// 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 Lesser General Public License
// along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
// $Revision: $
// $Author: $
// $Date: $
//
//=============================================================================
//=============================================================================
//
// CLASS StencilRefNode - IMPLEMENTATION
//
//=============================================================================
//== INCLUDES =================================================================
#include "StencilRefNode.hh"
//== NAMESPACES ===============================================================
namespace ACG {
namespace SceneGraph {
//== IMPLEMENTATION ==========================================================
StencilRefNode::StencilRefNode (BaseNode* _parent,
const std::string& _name)
: BaseNode(_parent, _name),
reference_ (0)
{}
//----------------------------------------------------------------------------
StencilRefNode::StencilRefNode (BaseNode* _parent,
BaseNode* _child,
const std::string& _name)
: BaseNode(_parent, _child, _name),
reference_ (0)
{}
//----------------------------------------------------------------------------
void StencilRefNode::enter(GLState& _state, unsigned int _drawmode)
{
glPushAttrib (GL_STENCIL_BUFFER_BIT);
glStencilFunc (GL_ALWAYS, reference_, ~0);
glStencilOp (GL_KEEP, GL_KEEP, GL_REPLACE);
}
//----------------------------------------------------------------------------
void StencilRefNode::leave(GLState& _state, unsigned int _drawmode)
{
glPopAttrib ();
}
//----------------------------------------------------------------------------
void StencilRefNode::enterPick(GLState& /*_state*/ ,
PickTarget /*_target*/,
unsigned int /*_drawMode*/ ) {
}
//----------------------------------------------------------------------------
void StencilRefNode::leavePick(GLState& /*_state*/,
PickTarget /*_target*/,
unsigned int /*_drawMode*/ ) {
}
void StencilRefNode::setReference(GLuint _ref)
{
reference_ = _ref;
}
//=============================================================================
} // namespace SceneGraph
} // namespace ACG
//=============================================================================
//=============================================================================
//
// OpenFlipper
// Copyright (C) 2009 by Computer Graphics Group, RWTH Aachen
// www.openflipper.org
//
//-----------------------------------------------------------------------------
//
// License
//
// 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.
//
// 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 Lesser General Public License
// along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
// $Revision: $
// $Author: $
// $Date: $
//
//=============================================================================
//=============================================================================
//
// CLASS StencilRefNode
//
//=============================================================================
#ifndef ACG_STENCILREF_NODE_HH
#define ACG_STENCILREF_NODE_HH
//== INCLUDES =================================================================
#include "BaseNode.hh"
//== NAMESPACES ===============================================================
namespace ACG {
namespace SceneGraph {
//== CLASS DEFINITION =========================================================
/** \class StencilRefNode StencilRefNode.hh <ACG/Scenegraph/StencilRefNode.hh>
Sets the stencil buffer reference for its child nodes
**/
class ACGDLLEXPORT StencilRefNode : public BaseNode
{
public:
/// Default constructor.
StencilRefNode (BaseNode* _parent = 0,
const std::string& _name = "<StencilRefNode>");
/// Put this node between _parent and _child
StencilRefNode (BaseNode* _parent,
BaseNode* _child,
const std::string& _name="<unknown>");
/// set class name
ACG_CLASSNAME(StencilRefNode);
/// set stencil reference number
void setReference (GLuint _ref);
/// set stencil reference for all z-pass pixels
void enter(GLState& _state, unsigned int _drawmode);
/// restores original stencil behavior
void leave(GLState& _state, unsigned int _drawmode);
/** \brief Do nothing in picking
*/
void enterPick(GLState& _state, PickTarget _target, unsigned int _drawMode );
/** \brief Do nothing in picking
*/
void leavePick(GLState& _state, PickTarget _target, unsigned int _drawMode );
private:
GLuint reference_;
};
//=============================================================================
} // namespace SceneGraph
} // namespace ACG
//=============================================================================
#endif // ACG_ENVMAP_NODE_HH defined
//=============================================================================
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