GlobeEngine
SceneStateSet.h
Go to the documentation of this file.
1 
9 #ifndef GlobeEngine_SceneStateSet_h
10 #define GlobeEngine_SceneStateSet_h
11 
12 #include "OpenGL_Includes.h"
13 #include <vector>
14 #include <vmmlib/vmmlib.hpp>
15 
16 namespace ge {
17  struct StencilFunction {
18  GLenum function;
19  GLint reference;
20  GLuint mask;
21  };
22 
24  GLenum fail;
25  GLenum zfail;
26  GLenum zpass;
27  };
28 
29  struct StencilBuffer {
30  GLint clearValue;
31  };
32 
33  struct ColorMask {
34  GLboolean red;
35  GLboolean green;
36  GLboolean blue;
37  GLboolean alpha;
38  };
39 
40 
42  {
43 
44  public:
45  SceneStateSet();
47  void clear();
48  void createBasicStateSet(std::string _name);
49  void apply();
50  void applyWithOutClear();
51  void print();
52 
53  void setPolygonMode(GLenum _mode);
54 
55  /* possible input GL_FRONT, GL_BACK, and GL_FRONT_AND_BACK */
56  void enableCullFaces(GLenum _mode = GL_BACK);
57  void changeCullMode(GLenum _mode);
58  void changeFrontFaceMode(GLenum _mode);
59  void disableCullFaces();
60 
61  void enableDepthMask();
62  void disableDepthMask();
63 
64  void setDepthTestEnabled(bool _in);
65  void enableDepthTest(GLenum _function);
66  void changeDepthFunction(GLenum _function);
67  void disableDepthTest();
68  void setDepthRange(double _near, double _far);
69 
70  void closeMatrixStack();
71 
76  void enableLineSmooth();
77  void disableLineSmooth();
78 
84  void setLineWidth(float _width);
85 
91  void setPolygonOffset(float _factor=0, float _units=0);
98  void enablePolygonOffsetMode(GLenum _mode);
99  void disablePolygonOffsetMode(GLenum _mode);
100 
101  // stencil related properties
102  void enableStencilTest();
103  void disableStencilTest();
104  void setStencilFunction(GLenum _function, GLint _reference, GLuint _mask);
105  void setStencilOperation(GLenum _fail, GLenum _zfail, GLenum _zpass);
106  void setStencilClearValue(GLint _in);
107 
108  void enableColorMask(GLboolean _r = GL_TRUE, GLboolean _g = GL_TRUE, GLboolean _b = GL_TRUE, GLboolean _a = GL_TRUE);
109  void disableColorMask(GLboolean _r = GL_FALSE, GLboolean _g = GL_FALSE, GLboolean _b = GL_FALSE, GLboolean _a = GL_FALSE);
110 
111  // blend function handling
112  void setBlendFunction(GLenum _sfactor, GLenum _dfactor);
113  void enableBlending();
114  void disableBlending();
115  void applyBlending();
116 
117  // clear color handling
118  vmml::Vector3f getBackgroundColor();
119  void setBackgroundColor(vmml::Vector3f _color);
120 
121  void clearFramebuffer();
122 
123  private:
124  void switchPolygonOffsetMode(GLenum _mode, bool _enabled);
125 
126  bool depthEnabled;
127  bool stencilEnabled;
128  bool faceCulling;
129  bool blendingEnabled;
130 
131  bool polygonOffsetModePoint;
132  bool polygonOffsetModeLine;
133  bool polygonOffsetModeFill;
134 
135  GLenum polygonMode;
136  GLenum faceCullingMode;
137  GLenum frontfaceMode;
138 
139  // depth buffer
140  bool depthMask;
141  GLenum depthFunction;
142  double depthNearValue;
143  double depthFarValue;
144 
145  // Blend properties
146  GLenum blendSourceFactor;
147  GLenum blendDestinationFactor;
148 
149  // Stencil
150  StencilBuffer stencilBuffer;
151  StencilFunction stencilTest;
152  StencilOperation stencilOperation;
153 
154  // Masken
155  ColorMask colorMask;
156 
157  /* scene properties */
158  // color to clear all buffers
159  vmml::Vector4f clearColor;
160  // color to fill Color Channel 0
161  vmml::Vector3f backgroundColor;
162 
163 
164  std::string name;
165  };
166 }
167 #endif
void changeFrontFaceMode(GLenum _mode)
Definition: SceneStateSet.cpp:132
void setDepthTestEnabled(bool _in)
Definition: SceneStateSet.cpp:150
void disableLineSmooth()
Definition: SceneStateSet.cpp:181
void disableColorMask(GLboolean _r=GL_FALSE, GLboolean _g=GL_FALSE, GLboolean _b=GL_FALSE, GLboolean _a=GL_FALSE)
Definition: SceneStateSet.cpp:297
void enableDepthMask()
Definition: SceneStateSet.cpp:275
void closeMatrixStack()
Definition: SceneStateSet.cpp:322
~SceneStateSet()
Definition: SceneStateSet.cpp:16
void print()
Definition: SceneStateSet.cpp:119
GLint reference
Definition: SceneStateSet.h:19
void disableDepthMask()
Definition: SceneStateSet.cpp:281
GLenum fail
Definition: SceneStateSet.h:24
void disableStencilTest()
Definition: SceneStateSet.cpp:239
Definition: SceneStateSet.h:17
void enableLineSmooth()
Definition: SceneStateSet.cpp:173
Definition: SceneStateSet.h:29
void apply()
Definition: SceneStateSet.cpp:83
void setPolygonOffset(float _factor=0, float _units=0)
Definition: SceneStateSet.cpp:228
void clear()
Definition: SceneStateSet.cpp:21
void disablePolygonOffsetMode(GLenum _mode)
Definition: SceneStateSet.cpp:202
void setStencilOperation(GLenum _fail, GLenum _zfail, GLenum _zpass)
Definition: SceneStateSet.cpp:314
Definition: SceneStateSet.h:33
void applyWithOutClear()
Definition: SceneStateSet.cpp:89
void clearFramebuffer()
Definition: SceneStateSet.cpp:69
vmml::Vector3f getBackgroundColor()
Definition: SceneStateSet.cpp:353
void enableDepthTest(GLenum _function)
Definition: SceneStateSet.cpp:155
void disableDepthTest()
Definition: SceneStateSet.cpp:167
GLuint mask
Definition: SceneStateSet.h:20
GLint clearValue
Definition: SceneStateSet.h:30
void enableStencilTest()
Definition: SceneStateSet.cpp:233
void applyBlending()
Definition: SceneStateSet.cpp:265
GLenum zpass
Definition: SceneStateSet.h:26
void enableColorMask(GLboolean _r=GL_TRUE, GLboolean _g=GL_TRUE, GLboolean _b=GL_TRUE, GLboolean _a=GL_TRUE)
Definition: SceneStateSet.cpp:288
void setPolygonMode(GLenum _mode)
Definition: SceneStateSet.cpp:330
void enableBlending()
Definition: SceneStateSet.cpp:252
GLboolean green
Definition: SceneStateSet.h:35
GLboolean blue
Definition: SceneStateSet.h:36
void changeCullMode(GLenum _mode)
Definition: SceneStateSet.cpp:138
GLboolean red
Definition: SceneStateSet.h:34
GLboolean alpha
Definition: SceneStateSet.h:37
void changeDepthFunction(GLenum _function)
Definition: SceneStateSet.cpp:161
void setLineWidth(float _width)
Definition: SceneStateSet.cpp:188
Definition: AvalancheTrainingSimulationEngine.h:28
void enableCullFaces(GLenum _mode=GL_BACK)
Definition: SceneStateSet.cpp:124
Definition: SceneStateSet.h:41
SceneStateSet()
Definition: SceneStateSet.cpp:11
GLenum zfail
Definition: SceneStateSet.h:25
void setStencilClearValue(GLint _in)
Definition: SceneStateSet.cpp:270
void setDepthRange(double _near, double _far)
Definition: SceneStateSet.cpp:344
void setBackgroundColor(vmml::Vector3f _color)
Definition: SceneStateSet.cpp:358
void setBlendFunction(GLenum _sfactor, GLenum _dfactor)
Definition: SceneStateSet.cpp:245
void createBasicStateSet(std::string _name)
Definition: SceneStateSet.cpp:55
void disableBlending()
Definition: SceneStateSet.cpp:259
Definition: SceneStateSet.h:23
void enablePolygonOffsetMode(GLenum _mode)
Definition: SceneStateSet.cpp:196
void disableCullFaces()
Definition: SceneStateSet.cpp:144
void setStencilFunction(GLenum _function, GLint _reference, GLuint _mask)
Definition: SceneStateSet.cpp:306