SimpleGL  1.1.0
A framework for platform independent rendering
gl_general.hpp
Go to the documentation of this file.
1 
8 #ifndef GL_GENERAL_HPP
9 #define GL_GENERAL_HPP
10 
11 #include <SimpleGL_gl/SimpleGL_gl_Export.h>
12 
13 #include <GL/glew.h>
14 
15 #include <glm/glm.hpp>
16 
17 #include "backend_gl.hpp"
18 
19 namespace sgl {
20 
26  enum class Capability : GLenum {
27 
29  BLEND = GL_BLEND,
30 
32  CULL_FACE = GL_CULL_FACE,
33 
35  DEPTH_TEST = GL_DEPTH_TEST
36  };
37 
43  enum class ClearBit : GLbitfield {
44 
46  COLOR_BUFFER_BIT = GL_COLOR_BUFFER_BIT,
47 
49  DEPTH_BUFFER_BIT = GL_DEPTH_BUFFER_BIT,
50 
52  STENCIL_BUFFER_BIT = GL_STENCIL_BUFFER_BIT
53  };
54 
60  enum class Primitive : GLenum {
61 
63  POINTS = GL_POINTS,
64 
66  LINES = GL_LINES,
67 
69  LINE_STRIP = GL_LINE_STRIP,
70 
72  LINE_LOOP = GL_LINE_LOOP,
73 
75  TRIANGLES = GL_TRIANGLES,
76 
78  TRIANGLE_STRIP = GL_TRIANGLE_STRIP,
79 
81  TRIANGLE_FAN = GL_TRIANGLE_FAN
82  };
83 
89  enum class BlendFactor : GLenum {
90 
92  ZERO = GL_ZERO,
93 
95  ONE = GL_ONE,
96 
98  SRC_COLOR = GL_SRC_COLOR,
99 
101  ONE_MINUS_SRC_COLOR = GL_ONE_MINUS_SRC_COLOR,
102 
104  DST_COLOR = GL_DST_COLOR,
105 
107  ONE_MINUS_DST_COLOR = GL_ONE_MINUS_DST_COLOR,
108 
110  SRC_ALPHA = GL_SRC_ALPHA,
111 
113  ONE_MINUS_SRC_ALPHA = GL_ONE_MINUS_SRC_ALPHA,
114 
116  DST_ALPHA = GL_DST_ALPHA,
117 
119  ONE_MINUS_DST_ALPHA = GL_ONE_MINUS_DST_ALPHA,
120 
122  CONSTANT_COLOR = GL_CONSTANT_COLOR,
123 
125  ONE_MINUS_CONSTANT_COLOR = GL_ONE_MINUS_CONSTANT_COLOR,
126 
128  CONSTANT_ALPHA = GL_CONSTANT_ALPHA,
129 
131  ONE_MINUS_CONSTANT_ALPHA = GL_ONE_MINUS_CONSTANT_ALPHA,
132 
134  SRC_ALPHA_SATURATE = GL_SRC_ALPHA_SATURATE,
135 
137  SRC1_COLOR = GL_SRC1_COLOR,
138 
140  ONE_MINUS_SRC1_COLOR = GL_ONE_MINUS_SRC1_COLOR,
141 
143  SRC1_ALPHA = GL_SRC1_ALPHA,
144 
146  ONE_MINUS_SRC1_ALPHA = GL_ONE_MINUS_SRC1_ALPHA
147  };
148 
154  enum class CullFaceMode : GLenum {
155 
157  FRONT = GL_FRONT,
158 
160  BACK = GL_BACK,
161 
163  FRONT_AND_BACK = GL_FRONT_AND_BACK
164  };
165 
171  enum class DepthFunction : GLenum {
172 
174  NEVER = GL_NEVER,
175 
177  LESS = GL_LESS,
178 
180  EQUAL = GL_EQUAL,
181 
183  LEQUAL = GL_LEQUAL,
184 
186  GREATER = GL_GREATER,
187 
189  NOTEQUAL = GL_NOTEQUAL,
190 
192  GEQUAL = GL_GEQUAL,
193 
195  ALWAYS = GL_ALWAYS
196  };
197 
204  inline ClearBit operator|(ClearBit left, ClearBit right) {
205  GLbitfield bitmask = to_GLbitfield(left) | to_GLbitfield(right);
206  return static_cast<ClearBit> (bitmask);
207  };
208 
214  class SIMPLEGL_GL_EXPORT GL {
215 
216  private:
218  GL(void);
219 
220  public:
222  static void checkError();
223 
229  static void enable(Capability cap);
230 
236  static void disable(Capability cap);
237 
246  static void clearColor(float r, float g, float b, float a);
247 
253  static void clearColor(glm::vec4 color);
254 
260  static void clear(ClearBit mask);
261 
269  static void drawArrays(Primitive mode, int first, int count);
270 
277  static void blendFunc(BlendFactor source, BlendFactor destination);
278 
284  static void cullFace(CullFaceMode mode);
285 
291  static void depthFunc(DepthFunction func);
292  };
293 }
294 
295 #endif /* GL_GENERAL_HPP */
Equivalent to GL_STENCIL_BUFFER_BIT.
Equivalent to GL_TRIANGLE_FAN.
Equivalent to GL_ONE_MINUS_SRC1_COLOR.
Equivalent to GL_CONSTANT_COLOR.
Equivalent to GL_POINTS.
Equivalent to GL_LESS.
ClearBit
This enum wraps the clear buffer bits.
Definition: gl_general.hpp:43
Primitive
This enum wraps Primitive types of OpenGL.
Definition: gl_general.hpp:60
Equivalent to GL_DEPTH_TEST.
Equivalent to GL_ALWAYS.
Equivalent to GL_BLEND.
Equivalent to GL_FRONT_AND_BACK.
Equivalent to GL_COLOR_BUFFER_BIT.
Equivalent to GL_LEQUAL.
Equivalent to GL_DST_ALPHA.
Equivalent to GL_SRC_ALPHA_SATURATE.
Equivalent to GL_ONE_MINUS_SRC_ALPHA.
Equivalent to GL_SRC_ALPHA.
Equivalent to GL_GREATER.
Equivalent to GL_DEPTH_BUFFER_BIT.
Equivalent to GL_SRC1_ALPHA.
Equivalent to GL_LINE_LOOP.
Generic namespace for the SimpleGL framework.
Definition: application.hpp:18
Equivalent to GL_CONSTANT_ALPHA.
DepthFunction
This enum wraps the depth functions.
Definition: gl_general.hpp:171
Equivalent to GL_ONE_MINUS_CONSTANT_COLOR.
Equivalent to GL_ONE_MINUS_DST_COLOR.
Equivalent to GL_EQUAL.
CullFaceMode
This enum wraps the face culling modes.
Definition: gl_general.hpp:154
Equivalent to GL_FRONT.
Equivalent to GL_LINES.
Equivalent to GL_ONE.
Equivalent to GL_ONE_MINUS_SRC1_ALPHA.
Equivalent to GL_SRC_COLOR.
Equivalent to GL_NEVER.
Equivalent to GL_ONE_MINUS_SRC_COLOR.
This static class wraps general OpenGL functions.
Definition: gl_general.hpp:214
Equivalent to GL_BLEND.
Equivalent to GL_GEQUAL.
BlendFactor
This enum wraps the blend factos.
Definition: gl_general.hpp:89
Equivalent to GL_ONE_MINUS_DST_ALPHA.
GLbitfield to_GLbitfield(E e)
Gets the GLbitfield value from an enum class.
Definition: backend_gl.tcc:27
Modifier operator|(Modifier left, Modifier right)
Overloaded OR operator for the modifier bit.
Definition: input.hpp:478
Equivalent to GL_TRIANGLE_STRIP.
Equivalent to GL_NOTEQUAL.
Equivalent to GL_TRIANGLES.
Equivalent to GL_LINE_STRIP.
Equivalent to GL_SRC1_COLOR.
Equivalent to GL_ONE_MINUS_CONSTANT_ALPHA.
Equivalent to GL_ZERO.
Equivalent to GL_DST_COLOR.
Capability
This enum wraps OpenGL capabilities.
Definition: gl_general.hpp:26
Equivalent to GL_BACK.