A thin wrapper around an OpenGL Vertex Array Object (VAO).
More...
#include <easy3d/renderer/vertex_array_object.h>
|
| VertexArrayObject () |
| Constructor.
|
|
| ~VertexArrayObject () |
| Destructor.
|
|
GLuint | id () const |
| Get the OpenGL ID of the VAO.
|
|
void | bind () |
| Bind the VAO.
|
|
void | release () const |
| Release the VAO.
|
|
bool | create_array_buffer (GLuint &buffer, GLuint index, const void *data, std::size_t size, std::size_t dim, bool dynamic=false) |
| Creates an OpenGL array buffer and uploads data to the buffer.
|
|
bool | create_element_buffer (GLuint &buffer, const void *data, std::size_t size, bool dynamic=false) |
| Creates an OpenGL element buffer and uploads data to the buffer.
|
|
bool | create_storage_buffer (GLuint &buffer, GLuint index, const void *data, std::size_t size) |
| Creates an OpenGL shader storage buffer and uploads data to the buffer.
|
|
bool | update_storage_buffer (GLuint &buffer, GLintptr offset, GLsizeiptr size, const void *data) |
| Updates an OpenGL shader storage buffer with new data.
|
|
|
static bool | is_supported () |
| Check if VAOs are supported by the current OpenGL context.
|
|
static void | release_buffer (GLuint &buffer) |
| Frees the GPU memory of the buffer specified by 'buffer'.
|
|
static void | get_buffer_data (GLenum target, GLuint buffer, GLintptr offset, GLsizeiptr size, void *data) |
| Returns a subset of a buffer object's data store.
|
|
static void * | map_buffer (GLenum target, GLuint buffer, GLenum access) |
| Maps a buffer object's data store.
|
|
static void | unmap_buffer (GLenum target, GLuint buffer) |
| Unmaps a buffer object's data store.
|
|
A thin wrapper around an OpenGL Vertex Array Object (VAO).
A VAO is an OpenGL container object that encapsulates the state needed to specify per-vertex attribute data to the OpenGL pipeline. To put it another way, a VAO remembers the states of buffer objects (i.e., vertex buffers) and their associated state (e.g. vertex attribute divisors). This allows a very easy and efficient method of switching between OpenGL buffer states for rendering different "objects" in a scene.
- Note
- This implementation is more than the standard VAO. It also provides functions for creating and managing other buffer objects (i.e., shader storage buffer).
◆ ~VertexArrayObject()
Destructor.
Deletes the VAO and frees the associated OpenGL resources.
◆ bind()
Bind the VAO.
Makes the VAO the current VAO in the OpenGL context.
◆ create_array_buffer()
bool create_array_buffer |
( |
GLuint & | buffer, |
|
|
GLuint | index, |
|
|
const void * | data, |
|
|
std::size_t | size, |
|
|
std::size_t | dim, |
|
|
bool | dynamic = false ) |
Creates an OpenGL array buffer and uploads data to the buffer.
- Parameters
-
buffer | The name of the buffer object. |
index | The index of the generic vertex attribute to be enabled. |
data | The pointer to the data. |
size | The size of the data in bytes. |
dim | The number of components per generic vertex attribute. Must be 1, 2, 3, or 4. |
dynamic | The expected usage pattern is GL_STATIC_DRAW or GL_DYNAMIC_DRAW. |
- Returns
- True if the buffer was created successfully, false otherwise.
◆ create_element_buffer()
bool create_element_buffer |
( |
GLuint & | buffer, |
|
|
const void * | data, |
|
|
std::size_t | size, |
|
|
bool | dynamic = false ) |
Creates an OpenGL element buffer and uploads data to the buffer.
- Parameters
-
buffer | The name of the buffer object. |
data | The pointer to the data. |
size | The size of the data in bytes. |
dynamic | The expected usage pattern is GL_STATIC_DRAW or GL_DYNAMIC_DRAW. |
- Returns
- True if the buffer was created successfully, false otherwise.
◆ create_storage_buffer()
bool create_storage_buffer |
( |
GLuint & | buffer, |
|
|
GLuint | index, |
|
|
const void * | data, |
|
|
std::size_t | size ) |
Creates an OpenGL shader storage buffer and uploads data to the buffer.
- Parameters
-
buffer | The name of the buffer object. |
index | The index of the binding point. |
data | The pointer to the data. |
size | The size of the data in bytes. |
- Returns
- True if the buffer was created successfully, false otherwise.
◆ get_buffer_data()
void get_buffer_data |
( |
GLenum | target, |
|
|
GLuint | buffer, |
|
|
GLintptr | offset, |
|
|
GLsizeiptr | size, |
|
|
void * | data ) |
|
static |
Returns a subset of a buffer object's data store.
- Parameters
-
target | The target buffer object. Can be GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER, GL_SHADER_STORAGE_BUFFER, etc. |
buffer | The name of the buffer object. |
offset | The offset into the buffer object's data store from which data will be returned, measured in bytes. |
size | The size in bytes of the data store region being returned. |
data | A pointer to the location where buffer object data is returned. |
◆ id()
Get the OpenGL ID of the VAO.
- Returns
- The OpenGL ID of the VAO.
◆ is_supported()
Check if VAOs are supported by the current OpenGL context.
- Returns
- True if VAOs are supported, false otherwise.
◆ map_buffer()
void * map_buffer |
( |
GLenum | target, |
|
|
GLuint | buffer, |
|
|
GLenum | access ) |
|
static |
Maps a buffer object's data store.
- Parameters
-
target | The target buffer object. Can be GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER, GL_SHADER_STORAGE_BUFFER, etc. |
buffer | The name of the buffer object. |
access | The access policy. Must be GL_READ_ONLY, GL_WRITE_ONLY, or GL_READ_WRITE. |
- Returns
- A pointer to the mapped data store.
◆ release()
Release the VAO.
Unbinds the VAO from the OpenGL context.
◆ release_buffer()
void release_buffer |
( |
GLuint & | buffer | ) |
|
|
static |
Frees the GPU memory of the buffer specified by 'buffer'.
- Parameters
-
buffer | The name of the buffer object. |
◆ unmap_buffer()
void unmap_buffer |
( |
GLenum | target, |
|
|
GLuint | buffer ) |
|
static |
Unmaps a buffer object's data store.
- Parameters
-
target | The target buffer object. Can be GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER, GL_SHADER_STORAGE_BUFFER, etc. |
buffer | The name of the buffer object. |
◆ update_storage_buffer()
bool update_storage_buffer |
( |
GLuint & | buffer, |
|
|
GLintptr | offset, |
|
|
GLsizeiptr | size, |
|
|
const void * | data ) |
Updates an OpenGL shader storage buffer with new data.
- Parameters
-
buffer | The name of the buffer object. |
offset | The offset into the buffer object's data store where data replacement will begin, measured in bytes. |
size | The size in bytes of the data store region being replaced. |
data | The pointer to the new data. |
- Returns
- True if the buffer was updated successfully, false otherwise.
The documentation for this class was generated from the following files:
- G:/3_code/Easy3D/easy3d/renderer/vertex_array_object.h
- G:/3_code/Easy3D/easy3d/renderer/vertex_array_object.cpp