Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
openglobjects.h
Go to the documentation of this file.
1 
18 #ifndef ION_GFX_OPENGLOBJECTS_H_
19 #define ION_GFX_OPENGLOBJECTS_H_
20 
21 #include <vector>
22 
23 #include "ion/base/variant.h"
24 #include "ion/math/matrix.h"
25 #include "ion/math/vector.h"
26 #include "ion/portgfx/glheaders.h"
27 
28 namespace ion {
29 namespace gfx {
30 
41 template <typename T>
42 struct ArrayInfo : T {
43  struct Attribute {
45  : buffer(0U),
46  enabled(GL_FALSE),
47  size(4U),
48  stride(0U),
49  type(GL_FLOAT),
50  normalized(GL_FALSE),
51  pointer(NULL),
52  value(0.f, 0.f, 0.f, 1.f),
53  divisor(0U) {}
55  GLuint buffer;
57  GLboolean enabled;
60  GLuint size;
62  GLuint stride;
66  GLenum type;
68  GLboolean normalized;
70  GLvoid* pointer;
72  math::Vector4f value;
77  GLuint divisor;
78  };
80  std::vector<Attribute> attributes;
81 };
82 
84 template <typename T>
85 struct BufferInfo : T {
87  : size(-1),
88  usage(0),
89  mapped_data(NULL) {}
91  GLsizeiptr size;
94  GLenum usage;
96  GLvoid* mapped_data;
97 };
98 
100 template <typename T>
101 struct FramebufferInfo : T {
102  struct Attachment {
103  Attachment() : type(GL_NONE), value(0), level(0), cube_face(0) {}
106  GLenum type;
109  GLuint value;
111  GLuint level;
114  GLenum cube_face;
115  };
121 };
122 
124 template <typename T>
125 struct ProgramInfo : T {
127  struct Attribute {
128  Attribute() : index(0), type(GL_NONE), size(0U) {}
130  GLint index;
134  std::vector<GLint> array_indices;
137  GLenum type;
139  GLint size;
141  std::string name;
142  };
144  struct Uniform {
145  typedef base::Variant<
146  int, uint32, float,
147  math::VectorBase2f, math::VectorBase3f, math::VectorBase4f,
148  math::VectorBase2i, math::VectorBase3i, math::VectorBase4i,
149  math::VectorBase2ui, math::VectorBase3ui, math::VectorBase4ui,
151  Uniform() : index(0U), type(GL_FLOAT), size(0U) {}
153  GLint index;
157  std::vector<GLint> array_indices;
159  GLenum type;
161  GLint size;
165  std::string name;
166  };
168  struct Varying {
169  Varying() : index(0), type(GL_NONE), size(0U) {}
171  GLint index;
175  std::vector<GLint> array_indices;
178  GLenum type;
180  GLint size;
182  std::string name;
183  };
185  : vertex_shader(0U),
186  fragment_shader(0U),
187  delete_status(GL_FALSE),
188  link_status(GL_FALSE),
189  validate_status(GL_FALSE) {}
195  std::vector<Attribute> attributes;
196  std::vector<Uniform> uniforms;
197  std::vector<Varying> varyings;
199  GLboolean delete_status;
200  GLboolean link_status;
201  GLboolean validate_status;
203  std::string info_log;
204 };
205 
207 template <typename T>
208 struct RenderbufferInfo : T {
210  : width(0),
211  height(0),
212  internal_format(GL_RGBA4),
213  red_size(0),
214  green_size(0),
215  blue_size(0),
216  alpha_size(0),
217  depth_size(0),
218  stencil_size(0),
219  multisample_samples(0) {}
221  GLsizei width;
222  GLsizei height;
226  GLsizei red_size;
227  GLsizei green_size;
228  GLsizei blue_size;
229  GLsizei alpha_size;
230  GLsizei depth_size;
231  GLsizei stencil_size;
233 };
234 
236 template <typename T>
237 struct SamplerInfo : T {
239  : compare_func(GL_LESS),
240  compare_mode(GL_NONE),
241  max_anisotropy(1.f),
242  min_lod(-1000.f),
243  max_lod(1000.f),
244  min_filter(GL_NEAREST_MIPMAP_LINEAR),
245  mag_filter(GL_LINEAR),
246  wrap_r(GL_REPEAT),
247  wrap_s(GL_REPEAT),
248  wrap_t(GL_REPEAT) {}
250  GLenum compare_func;
251  GLenum compare_mode;
253  GLfloat max_anisotropy;
255  GLfloat min_lod;
256  GLfloat max_lod;
258  GLenum min_filter;
259  GLenum mag_filter;
261  GLenum wrap_r;
262  GLenum wrap_s;
263  GLenum wrap_t;
264 };
265 
267 template <typename T>
268 struct ShaderInfo : T {
270  : type(static_cast<GLenum>(-1)),
271  delete_status(GL_FALSE),
272  compile_status(GL_FALSE) {}
274  GLenum type;
276  GLboolean delete_status;
277  GLboolean compile_status;
279  std::string source;
281  std::string info_log;
282 };
283 
285 template <typename T>
286 struct SyncInfo : T {
288  : type(static_cast<GLenum>(-1)),
289  status(static_cast<GLenum>(-1)),
290  condition(static_cast<GLenum>(-1)),
291  flags(0) {}
293  GLenum type;
295  GLenum status;
297  GLenum condition;
299  GLbitfield flags;
300 };
301 
303 template <typename T>
306  : target(GL_TRANSFORM_FEEDBACK_BUFFER),
307  varyings(nullptr),
308  status(static_cast<GLenum>(-1)),
309  primitive_count(0) {}
311  GLenum target;
314  const char** varyings;
316  GLenum status;
320 };
321 
323 template <typename T>
324 struct TextureInfo : T {
326  : base_level(0),
327  max_level(1000),
328  compare_func(GL_LESS),
329  compare_mode(GL_NONE),
330  max_anisotropy(1.f),
331  min_lod(-1000.f),
332  max_lod(1000.f),
333  min_filter(GL_NEAREST_MIPMAP_LINEAR),
334  mag_filter(GL_LINEAR),
335  samples(0),
337  swizzle_r(GL_RED),
338  swizzle_g(GL_GREEN),
339  swizzle_b(GL_BLUE),
340  swizzle_a(GL_ALPHA),
341  wrap_r(GL_REPEAT),
342  wrap_s(GL_REPEAT),
343  wrap_t(GL_REPEAT),
344  target(static_cast<GLenum>(-1))
345  {}
346  GLint base_level;
347  GLint max_level;
349  GLenum compare_func;
350  GLenum compare_mode;
352  GLfloat max_anisotropy;
354  GLfloat min_lod;
355  GLfloat max_lod;
357  GLenum min_filter;
358  GLenum mag_filter;
360  GLuint samples;
363  GLenum swizzle_r;
364  GLenum swizzle_g;
365  GLenum swizzle_b;
366  GLenum swizzle_a;
368  GLenum wrap_r;
369  GLenum wrap_s;
370  GLenum wrap_t;
372  GLenum target;
373 };
374 
376 template <typename T>
377 struct TimerInfo : T {
379  : mode(kNone),
380  timestamp(0),
381  duration(0),
382  deleted(false),
383  is_data_available(false) {}
384  enum Mode {
391  };
399  bool deleted;
402 };
403 
404 } // namespace gfx
405 } // namespace ion
406 
407 #endif // ION_GFX_OPENGLOBJECTS_H_
GLint size
The number of components in the varying.
GLenum condition
The sync object condition.
uint64 duration
Duration data, if used as a begin/end query pair.
A ShaderInfo corresponds to an OpenGL Shader Object.
base::Variant< int, uint32, float, math::VectorBase2f, math::VectorBase3f, math::VectorBase4f, math::VectorBase2i, math::VectorBase3i, math::VectorBase4i, math::VectorBase2ui, math::VectorBase3ui, math::VectorBase4ui, math::Matrix2f, math::Matrix3f, math::Matrix4f > ValueType
GLboolean delete_status
The delete, link, and validate status.
A SamplerInfo corresponds to an OpenGL Sampler Object.
std::vector< GLint > array_indices
The attribute's array locations.
GLenum min_filter
The filter modes of the sampler.
GLvoid * mapped_data
The data pointer of the buffer if it is mapped, or NULL.
Definition: openglobjects.h:96
GLuint fragment_shader
The OpenGL id of the fragment shader of the program.
math::Vector4f value
The value of float and vec[2-4] attributes.
Definition: openglobjects.h:72
GLfloat min_lod
The min and max LOD of the sampler.
std::vector< Attribute > attributes
The attribute index of an attribute is its index in the vector.
Definition: openglobjects.h:80
GLuint level
The mipmap level of the texture object if one is attached.
GLint size
The number of components in the attribute.
GLint index
The uniform's location.
An attribute to a vertex shader.
GLboolean delete_status
The status of the shader.
GLenum wrap_r
The wrap modes of the sampler.
Mode mode
The usage mode of this timer query.
GLenum min_filter
The filter modes of the texture.
const char ** varyings
An array of count zero-terminated strings specifying the names of the varying variables to use for tr...
uint64 timestamp
Timestamp data, if used as a query counter or begin query.
Matrix< 3, float > Matrix3f
Definition: matrix.h:369
A SyncInfo corresponds to an OpenGL Sync Object.
GLbitfield flags
The sync object flags.
std::string info_log
The latest info log of the program.
GLuint vertex_shader
The OpenGL id of the vertex shader of the program.
GLenum cube_face
The cube map face of the texture if the attachment is a cube map texture object.
GLenum type
The type of the uniform.
Unused, so no known mode yet.
GLenum type
The type of the attribute, one of GL_FLOAT, GL_FLOAT_VEC2, GL_FLOAT_VEC3, GL_FLOAT_VEC4, GL_FLOAT_MAT2, GL_FLOAT_MAT3, or GL_FLOAT_MAT4.
Attachment color0
Attachments.
GLenum type
The type of the attachment, one of GL_RENDERBUFFER, GL_TEXTURE, or if no image is attached...
GLboolean normalized
Whether the attribute data will be normalized when sent to OpenGL.
Definition: openglobjects.h:68
GLsizei red_size
The size in bits of each channel in the renderbuffer's data stores.
std::vector< GLint > array_indices
The varying's array locations.
Is active, in use for begin/end query.
GLuint size
The number of values in each component of each element of the data array, e.g., a vec3 has size 3...
Definition: openglobjects.h:60
GLint index
The attribute index.
GLenum type
The type of the varying, one of GL_FLOAT, GL_FLOAT_VEC2, GL_FLOAT_VEC3, GL_FLOAT_VEC4, GL_FLOAT_MAT2, GL_FLOAT_MAT3, or GL_FLOAT_MAT4.
A TimerInfo corresponds to an OpenGL Timer Query Object.
A TransformFeedbackInfo corresponds to an OpenGL TransformFeedback Object.
GLenum status
The sync object status.
Is used as a query counter.
GLuint samples
Texture samples.
bool is_data_available
Is timestamp or duration available.
GLenum target
The generic buffer binding target GL_TRANSFORM_FEEDBACK_BUFFER.
The Matrix class defines a square N-dimensional matrix.
Definition: matrix.h:35
GLboolean fixed_sample_locations
GLenum wrap_r
The wrap modes of the texture.
GLfloat max_anisotropy
The max anisotropy of the sampler.
GLenum target
The texture target.
The Variant class is similar to boost::variant.
Definition: variant.h:201
GLsizei width
The dimensions of the renderbuffer.
GLenum usage
The usage pattern, one of GL_STREAM_DRAW, GL_STATIC_DRAW, or GL_DYNAMIC_DRAW.
Definition: openglobjects.h:94
A RenderbufferInfo corresponds to an OpenGL Renderbuffer Object.
GLenum type
The type of the attribute values in the data array.
Definition: openglobjects.h:66
GLuint divisor
The rate at which new attributes are presented to the vertex shader.
Definition: openglobjects.h:77
GLuint stride
The number of bytes between successive elements in the data array.
Definition: openglobjects.h:62
A ProgramInfo corresponds to an OpenGL Program Object.
GLint index
The varying index.
GLenum internal_format
The internal format of the renderbuffer.
std::vector< Varying > varyings
GLboolean enabled
Whether the attribute is enabled.
Definition: openglobjects.h:57
GLenum type
The sync object type.
std::string name
The name of the attribute in the program.
std::vector< GLint > array_indices
The uniform array locations.
GLuint buffer
The OpenGL name of the array buffer when the attribute pointer was set.
Definition: openglobjects.h:55
Matrix< 2, float > Matrix2f
Dimension- and type-specific typedefs.
Definition: matrix.h:367
ValueType value
The value of the uniform.
GLenum compare_func
The comparison function and mode of the sampler.
std::string info_log
The latest info log of the shader.
GLenum type
The shader type, either GL_VERTEX_SHADER or GL_FRAGMENT_SHADER.
A BufferInfo corresponds to an OpenGL Framebuffer Object.
GLenum status
The status of transform feedback: Whether it is active or paused.
GLsizeiptr size
The number of bytes of buffer data.
Definition: openglobjects.h:91
GLenum swizzle_r
The swizzle modes of the texture.
GLint size
The number of elements in the uniform. A non-array uniform has size 1.
A BufferInfo corresponds to an OpenGL Buffer Object.
Definition: openglobjects.h:85
std::string name
The name of the uniform in the program.
bool deleted
Was deleted.
GLvoid * pointer
The value of the attribute pointer.
Definition: openglobjects.h:70
std::vector< Uniform > uniforms
GLfloat min_lod
The min and max LOD of the texture.
std::vector< Attribute > attributes
The attributes, uniforms and varyings used in the program.
The below structs correspond to OpenGL "objects." For example, a BufferObject corresponds to an OpenG...
Definition: openglobjects.h:42
A TextureInfo corresponds to an OpenGL Texture Object.
GLuint value
The id of either the renderbuffer or texture bound to the attachment, or 0 if neither is bound...
std::string source
The source of the shader as a string.
GLenum compare_func
The comparison function and mode of the texture.
std::string name
The name of the varying in the program.
GLuint primitive_count
The count of primitives and so forth recorded by the current feedback operation, if available...
A varying to a fragment shader.
A uniform variable to a shader stage.
GLfloat max_anisotropy
The max anisotropy of the texture.