Page MenuHomec4science

glbuffer.h
No OneTemporary

File Metadata

Created
Wed, Dec 11, 15:43

glbuffer.h

#ifndef __GRAPHICS_BUFFER_H__
#define __GRAPHICS_BUFFER_H__
#include <QGLBuffer>
#include <vector>
struct GLGroup
{
GLGroup(GLenum primitive = GL_TRIANGLES) : primitive(primitive) {}
/* Render primitive type */
GLenum primitive;
/*
* Memory allocated by the ibo
* Each primitive type needs a certain number of vertices to
* compose a geometrical face.
*
* POINTS -> 1
* LINES -> 2
* TRIANGLES -> 3
* QUADS -> 4
*
* To better understand primitives: https://www.khronos.org/opengl/wiki/Primitive
*/
GLuint ibo_size;
};
/*
* Color array RGBA
*
* R := red
* G := green
* B := blue
* A := alpha (transparency)
*
* All values must be bound in the range [0, 1]
*/
struct color_s
{
GLfloat red, green, blue, alpha;
};
typedef GLuint texture_t;
struct GLBuffer
{
GLBuffer() : vbo(QGLBuffer::VertexBuffer), ibo(QGLBuffer::IndexBuffer), color{1, 1, 1, 1} {}
/*
* vbo := Vertex buffer object
* ibo := Index buffer object
*
* The static rendering process is made to optimize/reduce the calls to the processor and
* reduce drastically the memory occuped by a graphical object.
*
* A vbo is a list of all 3-dimensional coordinates in the space which correspond to
* the vertices of the object to draw.
* This list is not supposed to be ordered, but it's made to avoid repetitions on the coordinates.
*
* A ibo is a list which contains all the informations about how to combine all vertices
* present in the vbo.
* That information has a different format depending on the choise of the GLPrimitive.
* In short it contains all indices combinations needed point to the right vertices in the
* right order.
*
*/
QGLBuffer vbo, ibo;
/* Virtual size of the vbo buffer (memsize) */
GLuint vbo_size;
/*
* Color array RGBA
*
* R := red
* G := green
* B := blue
* A := alpha (transparency)
*
* All values must be bound in the range [0, 1]
*/
color_s color;
texture_t texture;
/*
* Array of groups which compose the ibo.
* A ibo can be composed of a multitude of structures.
* This parameter contains the information about the data structure
* used to read/loop into the ibo.
* (So an empty vector means an empty ibo too)
*/
std::vector<GLGroup> groups;
};
#endif

Event Timeline