Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
glfStencilBufferMode.hh
1 /*
2  This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4  Copyright (C) 2008, 2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10  BIAS is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation; either version 2.1 of the License, or
13  (at your option) any later version.
14 
15  BIAS is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with BIAS; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  */
24 
25 #ifndef __glfStencilBufferMode_hh__
26 #define __glfStencilBufferMode_hh__
27 
28 #include "glfCommon.hh"
29 
30 namespace BIAS {
31 
32  /**
33  * \brief Defines the usage of the stencil buffer.
34  * \ingroup g_openglframework
35  * \author bartczak 02/2009
36  */
37  class BIASOpenGLFramework_EXPORT glfStencilBufferMode {
38  public:
40 
41  virtual ~glfStencilBufferMode() {}
42 
43  /**
44  * Sets whether to use stencil buffer tests.
45  * \note: This must be enabled, even if you only want
46  * to write to the stencil buffer.
47  * \attention: Per default the test is disabled even if you
48  * create an instance and bind it.
49  */
50  void SetStencilTest(bool enable);
51 
52  /**
53  * Sets the mask of bits that shall be considered for stencil test from the
54  * stencil mask and the stencil buffer.
55  * The default is a the whole range of values.
56  */
57  void SetStencilMask(GLuint mask);
58 
59  /**
60  * Sets the stencil buffer comparison function.
61  * Valid values are: GL_NEVER, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GEQUAL, GL_GREATER,
62  * GL_NOTEQUAL, GL_ALWAYS.
63  */
64  void SetStencilFunc(GLenum comparisonFunc);
65 
66  /**
67  * Sets the reference value for the comprison function.
68  * Default is 0.
69  */
70  void SetReferenceValue(GLint referenceValue);
71 
72  /** Defines the operation of the stencil test.
73  * For each argument the valid values are: GL_KEEP, GL_ZERO, GL_REPLACE,
74  * GL_INCR, GL_INCR_WRAP, GL_DECR, GL_DECR_WRAP, GL_INVERT.
75  * The default is GL_KEEP for all arguments.
76  *
77  * \param stencilFail what shall to be done when the stencil compare test fails.
78  * \param stencilPassZFail what shall to be done when the stencil compare test passes but the z-buffer test fails.
79  * \param stencilPassZpass what shall to be done when the stencil compare test passes and the z-buffer test passes.
80  *
81  **/
82  void SetStencilOperation(GLenum stencilFail, GLenum stencilPassZFail, GLenum stencilPassZPass);
83 
84  /**
85  * Binds the stencil buffer mode.
86  */
87  void Bind() const;
88 
89  /**
90  * The default stencil buffer mode.
91  */
93 
94  private:
95  GLboolean enableTest_;
96  GLuint stencilMask_;
97  GLenum stencilFunc_;
98  GLint referenceValue_;
99 
100  GLenum stencilFail_;
101  GLenum stencilPassZFail_;
102  GLenum stencilPassZPass_;
103 
104  };
105 
106 } // namespace BIAS
107 
108 #endif // __glfStencilBufferMode_hh__
Defines the usage of the stencil buffer.
static const glfStencilBufferMode DEFAULT
The default stencil buffer mode.