StencilTwoSided
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library 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
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_STENCILTWOSIDED
#define OSG_STENCILTWOSIDED 1
#include <osg/Stencil>
namespace osg {
#ifndef GL_STENCIL_TEST_TWO_SIDE
#define GL_STENCIL_TEST_TWO_SIDE 0x8910
#endif
class OSG_EXPORT StencilTwoSided : public StateAttribute
{
public :
StencilTwoSided();
StencilTwoSided(const StencilTwoSided& stencil,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
META_StateAttribute(osg, StencilTwoSided, STENCIL);
virtual int compare(const StateAttribute& sa) const;
virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const
{
usage.usesMode(GL_STENCIL_TEST);
return true;
}
enum Face
{
FRONT = 0,
BACK = 1
};
enum Function
{
NEVER = GL_NEVER,
LESS = GL_LESS,
EQUAL = GL_EQUAL,
LEQUAL = GL_LEQUAL,
GREATER = GL_GREATER,
NOTEQUAL = GL_NOTEQUAL,
GEQUAL = GL_GEQUAL,
ALWAYS = GL_ALWAYS
};
inline void setFunction(Face face, Function func,int ref,unsigned int mask)
{
_func[face] = func;
_funcRef[face] = ref;
_funcMask[face] = mask;
}
inline void setFunction(Face face, Function func) { _func[face] = func; }
inline Function getFunction(Face face) const { return _func[face]; }
inline void setFunctionRef(Face face, int ref) { _funcRef[face]=ref; }
inline int getFunctionRef(Face face) const { return _funcRef[face]; }
inline void setFunctionMask(Face face, unsigned int mask) { _funcMask[face]=mask; }
inline unsigned int getFunctionMask(Face face) const { return _funcMask[face]; }
enum Operation
{
KEEP = GL_KEEP,
ZERO = GL_ZERO,
REPLACE = GL_REPLACE,
INCR = GL_INCR,
DECR = GL_DECR,
INVERT = GL_INVERT,
INCR_WRAP = GL_INCR_WRAP,
DECR_WRAP = GL_DECR_WRAP
};
inline void setOperation(Face face, Operation sfail, Operation zfail, Operation zpass)
{
_sfail[face] = sfail;
_zfail[face] = zfail;
_zpass[face] = zpass;
}
inline void setStencilFailOperation(Face face, Operation sfail) { _sfail[face] = sfail; }
inline Operation getStencilFailOperation(Face face) const { return _sfail[face]; }
inline void setStencilPassAndDepthFailOperation(Face face, Operation zfail) { _zfail[face]=zfail; }
inline Operation getStencilPassAndDepthFailOperation(Face face) const { return _zfail[face]; }
inline void setStencilPassAndDepthPassOperation(Face face, Operation zpass) { _zpass[face]=zpass; }
inline Operation getStencilPassAndDepthPassOperation(Face face) const { return _zpass[face]; }
inline void setWriteMask(Face face, unsigned int mask) { _writeMask[face] = mask; }
inline unsigned int getWriteMask(Face face) const { return _writeMask[face]; }
virtual void apply(State& state) const;
protected:
virtual ~StencilTwoSided();
Function _func[2];
int _funcRef[2];
unsigned int _funcMask[2];
Operation _sfail[2];
Operation _zfail[2];
Operation _zpass[2];
unsigned int _writeMask[2];
};
}
#endif
Stencil
GL_DECR_WRAP
#define GL_DECR_WRAP
Definition Stencil:23
GL_INCR_WRAP
#define GL_INCR_WRAP
Definition Stencil:22
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::Referenced::ref
int ref() const
Definition Referenced:161
osg::StateAttribute::StateAttribute
StateAttribute()
osg::StateAttribute::STENCIL
@ STENCIL
Definition StateAttribute:152
osg::State
Definition State:80
osg::StencilTwoSided::getFunctionMask
unsigned int getFunctionMask(Face face) const
Definition StencilTwoSided:91
osg::StencilTwoSided::setStencilPassAndDepthPassOperation
void setStencilPassAndDepthPassOperation(Face face, Operation zpass)
Definition StencilTwoSided:133
osg::StencilTwoSided::getFunction
Function getFunction(Face face) const
Definition StencilTwoSided:85
osg::StencilTwoSided::getModeUsage
virtual bool getModeUsage(StateAttribute::ModeUsage &usage) const
Definition StencilTwoSided:53
osg::StencilTwoSided::Face
Face
Definition StencilTwoSided:60
osg::StencilTwoSided::FRONT
@ FRONT
Definition StencilTwoSided:61
osg::StencilTwoSided::BACK
@ BACK
Definition StencilTwoSided:62
osg::StencilTwoSided::setStencilPassAndDepthFailOperation
void setStencilPassAndDepthFailOperation(Face face, Operation zfail)
Definition StencilTwoSided:127
osg::StencilTwoSided::~StencilTwoSided
virtual ~StencilTwoSided()
osg::StencilTwoSided::setFunctionMask
void setFunctionMask(Face face, unsigned int mask)
Definition StencilTwoSided:90
osg::StencilTwoSided::setWriteMask
void setWriteMask(Face face, unsigned int mask)
Definition StencilTwoSided:139
osg::StencilTwoSided::META_StateAttribute
META_StateAttribute(osg, StencilTwoSided, STENCIL)
osg::StencilTwoSided::_funcMask
unsigned int _funcMask[2]
Definition StencilTwoSided:152
osg::StencilTwoSided::setStencilFailOperation
void setStencilFailOperation(Face face, Operation sfail)
Definition StencilTwoSided:121
osg::StencilTwoSided::_writeMask
unsigned int _writeMask[2]
Definition StencilTwoSided:158
osg::StencilTwoSided::_func
Function _func[2]
Definition StencilTwoSided:150
osg::StencilTwoSided::getFunctionRef
int getFunctionRef(Face face) const
Definition StencilTwoSided:88
osg::StencilTwoSided::StencilTwoSided
StencilTwoSided()
osg::StencilTwoSided::_zfail
Operation _zfail[2]
Definition StencilTwoSided:155
osg::StencilTwoSided::getWriteMask
unsigned int getWriteMask(Face face) const
Definition StencilTwoSided:141
osg::StencilTwoSided::getStencilFailOperation
Operation getStencilFailOperation(Face face) const
Definition StencilTwoSided:124
osg::StencilTwoSided::compare
virtual int compare(const StateAttribute &sa) const
osg::StencilTwoSided::setOperation
void setOperation(Face face, Operation sfail, Operation zfail, Operation zpass)
Definition StencilTwoSided:113
osg::StencilTwoSided::setFunction
void setFunction(Face face, Function func)
Definition StencilTwoSided:84
osg::StencilTwoSided::_zpass
Operation _zpass[2]
Definition StencilTwoSided:156
osg::StencilTwoSided::StencilTwoSided
StencilTwoSided(const StencilTwoSided &stencil, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
osg::StencilTwoSided::_sfail
Operation _sfail[2]
Definition StencilTwoSided:154
osg::StencilTwoSided::apply
virtual void apply(State &state) const
osg::StencilTwoSided::setFunction
void setFunction(Face face, Function func, int ref, unsigned int mask)
Definition StencilTwoSided:77
osg::StencilTwoSided::Operation
Operation
Definition StencilTwoSided:95
osg::StencilTwoSided::INVERT
@ INVERT
Definition StencilTwoSided:101
osg::StencilTwoSided::DECR
@ DECR
Definition StencilTwoSided:100
osg::StencilTwoSided::DECR_WRAP
@ DECR_WRAP
Definition StencilTwoSided:103
osg::StencilTwoSided::REPLACE
@ REPLACE
Definition StencilTwoSided:98
osg::StencilTwoSided::INCR_WRAP
@ INCR_WRAP
Definition StencilTwoSided:102
osg::StencilTwoSided::ZERO
@ ZERO
Definition StencilTwoSided:97
osg::StencilTwoSided::INCR
@ INCR
Definition StencilTwoSided:99
osg::StencilTwoSided::KEEP
@ KEEP
Definition StencilTwoSided:96
osg::StencilTwoSided::setFunctionRef
void setFunctionRef(Face face, int ref)
Definition StencilTwoSided:87
osg::StencilTwoSided::getStencilPassAndDepthFailOperation
Operation getStencilPassAndDepthFailOperation(Face face) const
Definition StencilTwoSided:130
osg::StencilTwoSided::getStencilPassAndDepthPassOperation
Operation getStencilPassAndDepthPassOperation(Face face) const
Definition StencilTwoSided:136
osg::StencilTwoSided::_funcRef
int _funcRef[2]
Definition StencilTwoSided:151
osg::StencilTwoSided::Function
Function
Definition StencilTwoSided:66
osg::StencilTwoSided::GREATER
@ GREATER
Definition StencilTwoSided:71
osg::StencilTwoSided::GEQUAL
@ GEQUAL
Definition StencilTwoSided:73
osg::StencilTwoSided::ALWAYS
@ ALWAYS
Definition StencilTwoSided:74
osg::StencilTwoSided::LESS
@ LESS
Definition StencilTwoSided:68
osg::StencilTwoSided::NOTEQUAL
@ NOTEQUAL
Definition StencilTwoSided:72
osg::StencilTwoSided::LEQUAL
@ LEQUAL
Definition StencilTwoSided:70
osg::StencilTwoSided::EQUAL
@ EQUAL
Definition StencilTwoSided:69
osg::StencilTwoSided::NEVER
@ NEVER
Definition StencilTwoSided:67
osg
Definition AlphaFunc:19
OSG_EXPORT
#define OSG_EXPORT
Definition osg/Export:39
osg::StateAttribute::ModeUsage
Definition StateAttribute:308
osg::StateAttribute::ModeUsage::usesMode
virtual void usesMode(GLMode mode)=0