OGLplus (0.52.0) a C++ wrapper for OpenGL

stencil_test.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 #ifndef OGLPLUS_CONTEXT_STENCIL_TEST_1201040722_HPP
14 #define OGLPLUS_CONTEXT_STENCIL_TEST_1201040722_HPP
15 
16 #include <oglplus/glfunc.hpp>
19 #include <oglplus/face_mode.hpp>
20 
21 namespace oglplus {
22 namespace context {
23 
25 
29 {
30 public:
32 
36  static void StencilFunc(
37  CompareFunction func,
38  GLint ref = GLint(0),
39  GLuint mask = ~GLuint(0)
40  )
41  {
42  OGLPLUS_GLFUNC(StencilFunc)(GLenum(func), ref, mask);
43  OGLPLUS_VERIFY(
45  Error,
46  EnumParam(func)
47  );
48  }
49 
51 
55  static void StencilFuncSeparate(
56  Face face,
57  CompareFunction func,
58  GLint ref = GLint(0),
59  GLuint mask = ~GLuint(0)
60  )
61  {
62  OGLPLUS_GLFUNC(StencilFuncSeparate)(
63  GLenum(face),
64  GLenum(func),
65  ref,
66  mask
67  );
68  OGLPLUS_VERIFY(
70  Error,
71  EnumParam(func)
72  );
73  }
74 
76 
80  static void StencilOp(
81  StencilOperation sfail,
82  StencilOperation dfail,
83  StencilOperation dpass
84  )
85  {
86  OGLPLUS_GLFUNC(StencilOp)(
87  GLenum(sfail),
88  GLenum(dfail),
89  GLenum(dpass)
90  );
91  OGLPLUS_VERIFY_SIMPLE(StencilOp);
92  }
93 
95 
99  static void StencilOpSeparate(
100  Face face,
101  StencilOperation sfail,
102  StencilOperation dfail,
103  StencilOperation dpass
104  )
105  {
106  OGLPLUS_GLFUNC(StencilOpSeparate)(
107  GLenum(face),
108  GLenum(sfail),
109  GLenum(dfail),
110  GLenum(dpass)
111  );
112  OGLPLUS_VERIFY_SIMPLE(StencilOpSeparate);
113  }
114 
116 
122  static CompareFunction StencilFunc(bool backface = false)
123  {
124  GLint result;
125  OGLPLUS_GLFUNC(GetIntegerv)(
126  backface?
127  GL_STENCIL_BACK_FUNC:
128  GL_STENCIL_FUNC,
129  &result
130  );
131  OGLPLUS_VERIFY_SIMPLE(GetIntegerv);
132  return CompareFunction(result);
133  }
134 
135  static CompareFunction StencilFunc(Face face)
136  {
137  return StencilFunc(face == Face::Back);
138  }
139 
141 
147  static GLuint StencilValueMask(bool backface = false)
148  {
149  GLint result;
150  OGLPLUS_GLFUNC(GetIntegerv)(
151  backface?
152  GL_STENCIL_BACK_VALUE_MASK:
153  GL_STENCIL_VALUE_MASK,
154  &result
155  );
156  OGLPLUS_VERIFY_SIMPLE(GetIntegerv);
157  return GLuint(result);
158  }
159 
160  static GLuint StencilValueMask(Face face)
161  {
162  return StencilValueMask(face == Face::Back);
163  }
164 
166 
172  static GLuint StencilRef(bool backface = false)
173  {
174  GLint result;
175  OGLPLUS_GLFUNC(GetIntegerv)(
176  backface?
177  GL_STENCIL_BACK_REF:
178  GL_STENCIL_REF,
179  &result
180  );
181  OGLPLUS_VERIFY_SIMPLE(GetIntegerv);
182  return GLuint(result);
183  }
184 
185  static GLuint StencilRef(Face face)
186  {
187  return StencilRef(face == Face::Back);
188  }
189 
191 
197  static StencilOperation StencilFail(bool backface = false)
198  {
199  GLint result;
200  OGLPLUS_GLFUNC(GetIntegerv)(
201  backface?
202  GL_STENCIL_BACK_FAIL:
203  GL_STENCIL_FAIL,
204  &result
205  );
206  OGLPLUS_VERIFY_SIMPLE(GetIntegerv);
207  return StencilOperation(result);
208  }
209 
210  static StencilOperation StencilFail(Face face)
211  {
212  return StencilFail(face == Face::Back);
213  }
214 
216 
222  static StencilOperation StencilPassDepthFail(bool backface = false)
223  {
224  GLint result;
225  OGLPLUS_GLFUNC(GetIntegerv)(
226  backface?
227  GL_STENCIL_BACK_PASS_DEPTH_FAIL:
228  GL_STENCIL_PASS_DEPTH_FAIL,
229  &result
230  );
231  OGLPLUS_VERIFY_SIMPLE(GetIntegerv);
232  return StencilOperation(result);
233  }
234 
236  {
237  return StencilPassDepthFail(face == Face::Back);
238  }
239 
241 
247  static StencilOperation StencilPassDepthPass(bool backface = false)
248  {
249  GLint result;
250  OGLPLUS_GLFUNC(GetIntegerv)(
251  backface?
252  GL_STENCIL_BACK_PASS_DEPTH_PASS:
253  GL_STENCIL_PASS_DEPTH_PASS,
254  &result
255  );
256  OGLPLUS_VERIFY_SIMPLE(GetIntegerv);
257  return StencilOperation(result);
258  }
259 
261  {
262  return StencilPassDepthPass(face == Face::Back);
263  }
264 
265 };
266 
267 } // namespace context
268 } // namespace oglplus
269 
270 #endif // include guard
static void StencilFunc(CompareFunction func, GLint ref=GLint(0), GLuint mask=~GLuint(0))
Sets the stencil function.
Definition: stencil_test.hpp:36
static void StencilOp(StencilOperation sfail, StencilOperation dfail, StencilOperation dpass)
Sets the stencil operation.
Definition: stencil_test.hpp:80
static StencilOperation StencilPassDepthPass(bool backface=false)
Returns the stencil-pass depth-pass action.
Definition: stencil_test.hpp:247
Wrapper for the stencil-buffer-related operations.
Definition: stencil_test.hpp:28
static StencilOperation StencilFail(bool backface=false)
Returns the stencil-fail action.
Definition: stencil_test.hpp:197
Face
Polygon facing enumeration.
Definition: face_mode.hpp:34
OpenGL face type-related enumeration.
OpenGL test/comparison function enumeration.
Helper macro for optional checking of availability of GL function.
static CompareFunction StencilFunc(bool backface=false)
Returns the stencil function.
Definition: stencil_test.hpp:122
OpenGL stencil operation enumeration.
Exception class for general OpenGL errors.
Definition: basic.hpp:43
StencilOperation
Stencil operation type enumeration.
Definition: stencil_operation.hpp:27
static StencilOperation StencilPassDepthFail(bool backface=false)
Returns the stencil-pass depth-fail action.
Definition: stencil_test.hpp:222
static GLuint StencilRef(bool backface=false)
Returns the stencil reference value.
Definition: stencil_test.hpp:172
static void StencilOpSeparate(Face face, StencilOperation sfail, StencilOperation dfail, StencilOperation dpass)
Sets the stencil operation separately for front and back faces.
Definition: stencil_test.hpp:99
static void StencilFuncSeparate(Face face, CompareFunction func, GLint ref=GLint(0), GLuint mask=~GLuint(0))
Sets the stencil function separately for front and back faces.
Definition: stencil_test.hpp:55
CompareFunction
Comparison function type enumeration.
Definition: compare_function.hpp:30
static GLuint StencilValueMask(bool backface=false)
Returns the value of stencil mask.
Definition: stencil_test.hpp:147

Copyright © 2010-2014 Matúš Chochlík, University of Žilina, Žilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Mon Sep 22 2014 by Doxygen (version 1.8.6).