hx3d  1
2D/3D Simple Game Framework
stencil.hpp
1 /*
2  Stencil buffer management.
3  Copyright (C) 2015 Denis BOURGE
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18  USA
19 */
20 
21 #ifndef HX3D_GRAPHICS_STENCIL
22 #define HX3D_GRAPHICS_STENCIL
23 
24 #include "hx3d/graphics/gl.hpp"
25 
26 namespace hx3d {
27 namespace graphics {
28 
34 class Stencil {
35 public:
39  enum class Function {
41  Never = 0,
43  Always,
45  Equal,
47  NotEqual,
49  Less,
51  Greater,
56  };
57 
61  enum class Operation {
63  Keep = 0,
65  Zero,
67  Replace,
69  Increment,
71  IncrementWrap,
73  Decrement,
75  DecrementWrap,
77  Invert
78  };
79 
83  static void enable();
84 
88  static void disable();
89 
97  void setFunction(Function func, int ref, int mask);
98 
106  void setOperation(Operation sfail, Operation dpfail, Operation dppass);
107 
111  void begin();
112 
116  void end();
117 
118 private:
126  GLenum convertFunction(Function func);
134  GLenum convertOperation(Operation op);
135 };
136 
137 } /* graphics */
138 } /* hx3d */
139 
140 #endif
Function
Stencil function.
Definition: stencil.hpp:39
Hide when it's not equal.
void setFunction(Function func, int ref, int mask)
Set the stencil function.
Definition: stencil.cpp:34
static void disable()
Disable stencil mode.
Definition: stencil.cpp:30
2D stencil drawing.
Definition: stencil.hpp:34
static void enable()
Enable stencil mode.
Definition: stencil.cpp:26
hx3d framework namespace
Definition: audio.hpp:26
void setOperation(Operation sfail, Operation dpfail, Operation dppass)
Set the stencil operation.
Definition: stencil.cpp:38
Hide when it's greater or equal.
Operation
Stencil operation.
Definition: stencil.hpp:61
Hide when it's less or equal.
Hide when it's greater.
void end()
End the stencil.
Definition: stencil.cpp:51
void begin()
Begin to use the stencil.
Definition: stencil.cpp:42