OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StencilTwoSided.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2  *
3  * This library is open source and may be redistributed and/or modified under
4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5  * (at your option) any later version. The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * OpenSceneGraph Public License for more details.
12 */
13 
14 #ifndef OSG_STENCILTWOSIDED
15 #define OSG_STENCILTWOSIDED 1
16 
17 #include <osg/Stencil>
18 
19 namespace osg {
20 
21 #ifndef GL_STENCIL_TEST_TWO_SIDE
22 #define GL_STENCIL_TEST_TWO_SIDE 0x8910
23 #endif
24 
39 {
40  public :
41 
42 
44 
46  StencilTwoSided(const StencilTwoSided& stencil,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
47 
49 
51  virtual int compare(const StateAttribute& sa) const;
52 
53  virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const
54  {
55  usage.usesMode(GL_STENCIL_TEST);
56  return true;
57  }
58 
59  enum Face
60  {
61  FRONT = 0,
62  BACK = 1
63  };
64 
65  enum Function
66  {
67  NEVER = GL_NEVER,
68  LESS = GL_LESS,
69  EQUAL = GL_EQUAL,
70  LEQUAL = GL_LEQUAL,
71  GREATER = GL_GREATER,
72  NOTEQUAL = GL_NOTEQUAL,
73  GEQUAL = GL_GEQUAL,
74  ALWAYS = GL_ALWAYS
75  };
76 
77  inline void setFunction(Face face, Function func,int ref,unsigned int mask)
78  {
79  _func[face] = func;
80  _funcRef[face] = ref;
81  _funcMask[face] = mask;
82  }
83 
84  inline void setFunction(Face face, Function func) { _func[face] = func; }
85  inline Function getFunction(Face face) const { return _func[face]; }
86 
87  inline void setFunctionRef(Face face, int ref) { _funcRef[face]=ref; }
88  inline int getFunctionRef(Face face) const { return _funcRef[face]; }
89 
90  inline void setFunctionMask(Face face, unsigned int mask) { _funcMask[face]=mask; }
91  inline unsigned int getFunctionMask(Face face) const { return _funcMask[face]; }
92 
93 
94  enum Operation
95  {
96  KEEP = GL_KEEP,
97  ZERO = GL_ZERO,
98  REPLACE = GL_REPLACE,
99  INCR = GL_INCR,
100  DECR = GL_DECR,
101  INVERT = GL_INVERT,
102  INCR_WRAP = GL_INCR_WRAP,
103  DECR_WRAP = GL_DECR_WRAP
104  };
105 
113  inline void setOperation(Face face, Operation sfail, Operation zfail, Operation zpass)
114  {
115  _sfail[face] = sfail;
116  _zfail[face] = zfail;
117  _zpass[face] = zpass;
118  }
119 
121  inline void setStencilFailOperation(Face face, Operation sfail) { _sfail[face] = sfail; }
122 
124  inline Operation getStencilFailOperation(Face face) const { return _sfail[face]; }
125 
127  inline void setStencilPassAndDepthFailOperation(Face face, Operation zfail) { _zfail[face]=zfail; }
128 
130  inline Operation getStencilPassAndDepthFailOperation(Face face) const { return _zfail[face]; }
131 
133  inline void setStencilPassAndDepthPassOperation(Face face, Operation zpass) { _zpass[face]=zpass; }
134 
136  inline Operation getStencilPassAndDepthPassOperation(Face face) const { return _zpass[face]; }
137 
138 
139  inline void setWriteMask(Face face, unsigned int mask) { _writeMask[face] = mask; }
140 
141  inline unsigned int getWriteMask(Face face) const { return _writeMask[face]; }
142 
143 
144  virtual void apply(State& state) const;
145 
146  protected:
147 
148  virtual ~StencilTwoSided();
149 
150  Function _func[2];
151  int _funcRef[2];
152  unsigned int _funcMask[2];
153 
154  Operation _sfail[2];
155  Operation _zfail[2];
156  Operation _zpass[2];
157 
158  unsigned int _writeMask[2];
159 
160 };
161 
162 }
163 
164 #endif
#define OSG_EXPORT
Definition: Export.h:43
void setStencilPassAndDepthPassOperation(Face face, Operation zpass)
void setFunctionMask(Face face, unsigned int mask)
virtual bool getModeUsage(StateAttribute::ModeUsage &usage) const
unsigned int getFunctionMask(Face face) const
virtual void usesMode(GLMode mode)=0
void setOperation(Face face, Operation sfail, Operation zfail, Operation zpass)
Operation getStencilPassAndDepthFailOperation(Face face) const
void setStencilPassAndDepthFailOperation(Face face, Operation zfail)
unsigned int getWriteMask(Face face) const
void setWriteMask(Face face, unsigned int mask)
#define GL_INCR_WRAP
Definition: Stencil.h:22
void setFunction(Face face, Function func)
Function getFunction(Face face) const
int getFunctionRef(Face face) const
#define META_StateAttribute(library, name, type)
Operation getStencilFailOperation(Face face) const
void setStencilFailOperation(Face face, Operation sfail)
Definition: AlphaFunc.h:19
void setFunctionRef(Face face, int ref)
#define GL_DECR_WRAP
Definition: Stencil.h:23
void setFunction(Face face, Function func, int ref, unsigned int mask)
Operation getStencilPassAndDepthPassOperation(Face face) const