Easy3D 2.5.3
VertexArrayObject Class Reference

A thin wrapper around an OpenGL Vertex Array Object (VAO). More...

#include <easy3d/renderer/vertex_array_object.h>

Public Member Functions

GLuint id () const
 
void bind ()
 
void release () const
 
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 upload data to the buffer. More...
 
bool create_element_buffer (GLuint &buffer, const void *data, std::size_t size, bool dynamic=false)
 
bool create_storage_buffer (GLuint &buffer, GLuint index, const void *data, std::size_t size)
 
bool update_storage_buffer (GLuint &buffer, GLintptr offset, GLsizeiptr size, const void *data)
 

Static Public Member Functions

static bool is_supported ()
 
static void release_buffer (GLuint &buffer)
 Frees the GPU memory of the buffer specified by 'handle'.
 
static void get_buffer_data (GLenum target, GLuint buffer, GLintptr offset, GLsizeiptr size, void *data)
 
static void * map_buffer (GLenum target, GLuint buffer, GLenum access)
 
static void unmap_buffer (GLenum target, GLuint buffer)
 

Detailed Description

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).

Member Function Documentation

◆ 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 upload data to the buffer.

Parameters
handleThe name of the buffer object.
indexThe index of the generic vertex attribute to be enabled.
dataThe pointer to the data.
sizeThe size of the data in bytes.
dimThe number of components per generic vertex attribute. Must be 1, 2, 3, 4.
dynamicThe expected usage pattern is GL_STATIC_DRAW or GL_DYNAMIC_DRAW.
Returns
OpenGL error code.

◆ 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
targetcan be GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER, GL_SHADER_STORAGE_BUFFER, etc.
handlethe name of the buffer object.
offsetthe offset into the buffer object's data store from which data will be returned, measured in bytes.
sizethe size in bytes of the data store region being returned.
dataa pointer to the location where buffer object data is returned.

The documentation for this class was generated from the following files: