opengl_vbo_structure
OpenGL vertex buffer (VBO) holding one per-vertex or per-instance array of vec2, vec3 or vec4.
Derives from: opengl_gpu_buffer
Fields and methods
Members of the struct opengl_vbo_structure. Most of what you do with a CGP type goes through the free functions listed below.
Fields
GLuint divisor = 0 | Instancing divisor given to initialize_data_on_gpu: 0 for per-vertex data, 1 to advance once per instance (applied by opengl_set_vao_location). |
Methods
void initialize_data_on_gpu(numarray<vec3> const& data, GLuint divisor = 0) | Allocates a new VBO (glBufferData, GL_DYNAMIC_DRAW) holding the vec3 array and stores its id, size and divisor.3 overloads src |
void initialize_data_on_gpu(numarray<vec2> const& data, GLuint divisor = 0) | Allocates a new VBO (glBufferData, GL_DYNAMIC_DRAW) holding the vec2 array and stores its id, size and divisor. src |
void initialize_data_on_gpu(numarray<vec4> const& data, GLuint divisor = 0) | Allocates a new VBO (glBufferData, GL_DYNAMIC_DRAW) holding the vec4 array and stores its id, size and divisor. src |
| Prints a warning if the VBO was already allocated, whose memory is then lost. | |
void update(numarray<vec2> const& data, int size_elements_update = -1) | Overwrites the start of the VBO with the vec2 array (glBufferSubData, no reallocation), all of it or its first size_elements_update elements, and stops on an assertion if this exceeds the allocated size.3 overloads src |
void update(numarray<vec3> const& data, int size_elements_update = -1) | Overwrites the start of the VBO with the vec3 array (glBufferSubData, no reallocation), all of it or its first size_elements_update elements, and stops on an assertion if this exceeds the allocated size. src |
void update(numarray<vec4> const& data, int size_elements_update = -1) | Overwrites the start of the VBO with the vec4 array (glBufferSubData, no reallocation), all of it or its first size_elements_update elements, and stops on an assertion if this exceeds the allocated size. src |
Inherited from opengl_gpu_buffer (7 members)
Fields
GLuint id = 0 | OpenGL id of the buffer, 0 when it is not allocated. |
GLuint size = 0 | Number of elements in the buffer (a vec3 or a uint3 counts as one element), 0 when empty. |
GLenum type = 0 | OpenGL target of the buffer, GL_ARRAY_BUFFER for a VBO and GL_ELEMENT_ARRAY_BUFFER for an EBO. |
opengl_gpu_buffer_details details | Allocated size in bytes, number of components per element (2, 3 or 4) and component type (GL_FLOAT), used to describe the buffer to the VAO. |
Functions taking a opengl_vbo_structure
Other 1
void opengl_set_vao_location(opengl_vbo_structure const& vbo, GLuint location_index)Bind a VBO to a shader attribute location of the current VAO (glVertexAttribPointer), also setting the instancing divisor if the VBO has one.
Functions returning a opengl_vbo_structure
None.
Operators
None.