AireEngine
A 3D Open-World Game Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Aire::Buffer Class Reference

#include <buffer.h>

Public Member Functions

 Buffer (GLsizeiptr bufferSize, const void *data, GLbitfield flags=GL_DYNAMIC_STORAGE_BIT)
 
void setData (GLintptr offset, GLsizeiptr dataSize, const void *data)
 
void bindUniform (GLuint index, GLintptr offset, GLsizeiptr size)
 
void bindShaderStorage (GLuint index, GLintptr offset, GLsizeiptr size)
 
void bindTransformFeedback (GLuint index, GLintptr offset, GLsizeiptr size)
 
void bindAtomicCounter (GLuint index, GLintptr offset, GLsizeiptr size)
 
void bindVertAttrib (const VertexArrayObject &vao, GLuint bindingPoint, GLintptr offset, GLsizei stride)
 
void bindElementBuffer (const VertexArrayObject &vao)
 
GLuint getHandle () const
 
GLint64 getSize () const
 
 ~Buffer ()
 Destructor frees the associated OpenGL memory automatically.
 
 Buffer (const Buffer &)=delete
 
Bufferoperator= (const Buffer &)=delete
 

Detailed Description

A wrapper over an OpenGL buffer. Used to simplify buffer setup and to provide automatic clean-up.

Constructor & Destructor Documentation

◆ Buffer()

Buffer::Buffer ( GLsizeiptr bufferSize,
const void * data,
GLbitfield flags = GL_DYNAMIC_STORAGE_BIT )

Create and initialize an OpenGL buffer. See: https://registry.khronos.org/OpenGL-Refpages/gl4/html/glBufferStorage.xhtml

Parameters
bufferSizeThe size of the buffer to be allocated. Cannot be changed later.
dataA pointer to the data to be copied to the buffer. nullptr if data is not available yet.
flagsFlags used for buffer creation. Default one is GL_DYNAMIC_STORAGE_BIT.

Member Function Documentation

◆ bindAtomicCounter()

void Aire::Buffer::bindAtomicCounter ( GLuint index,
GLintptr offset,
GLsizeiptr size )
inline

Bind the buffer to an atomic counter binding point.

Parameters
indexThe uniform binding point to bind to.
offsetOffset within the buffer where the memory to be bound begins (in case only a subset of the buffer will be bound).
sizeSize of the memory block to be bound (in bytes).

◆ bindElementBuffer()

void Buffer::bindElementBuffer ( const VertexArrayObject & vao)

Bind the buffer as an element buffer holding faces that index into the vertex array.

Parameters
vaoThe vertex array object.
Here is the caller graph for this function:

◆ bindShaderStorage()

void Aire::Buffer::bindShaderStorage ( GLuint index,
GLintptr offset,
GLsizeiptr size )
inline

Bind the buffer to a shader storage binding point.

Parameters
indexThe shader storage binding point to bind to.
offsetOffset within the buffer where the memory to be bound begins (in case only a subset of the buffer will be bound).
sizeSize of the memory block to be bound (in bytes).

◆ bindTransformFeedback()

void Aire::Buffer::bindTransformFeedback ( GLuint index,
GLintptr offset,
GLsizeiptr size )
inline

Bind the buffer to a transform feedback binding point.

Parameters
indexThe transform feedback binding point to bind to.
offsetOffset within the buffer where the memory to be bound begins (in case only a subset of the buffer will be bound).
sizeSize of the memory block to be bound (in bytes).

◆ bindUniform()

void Buffer::bindUniform ( GLuint index,
GLintptr offset,
GLsizeiptr size )

Bind the buffer to a uniform binding point.

Parameters
indexThe uniform binding point to bind to.
offsetOffset within the buffer where the memory to be bound begins (in case only a subset of the buffer will be bound). The offset must be a multiple of GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, which on most platforms is 256.
sizeSize of the memory block to be bound (in bytes).

◆ bindVertAttrib()

void Buffer::bindVertAttrib ( const VertexArrayObject & vao,
GLuint bindingPoint,
GLintptr offset,
GLsizei stride )

Bind the buffer to a vertex attribute binding point.

Parameters
vaoThe vertex array object holding attribute specification.
bindingPointThe binding point of the attribute. We often set it to simply be the same as the attribute index.
offsetOffset within the buffer where the attribute memory begins.
strideNumber of bytes from the start where the next attribute is stored. Allows interleaved attributes.
Here is the caller graph for this function:

◆ getHandle()

GLuint Aire::Buffer::getHandle ( ) const
inline
Returns
The internal OpenGL handle to the buffer.

◆ getSize()

GLint64 Buffer::getSize ( ) const
Returns
The size of the buffer in bytes.
Here is the caller graph for this function:

◆ setData()

void Buffer::setData ( GLintptr offset,
GLsizeiptr dataSize,
const void * data )

Set data for (a part of) the buffer.

Parameters
offsetThe offset in the buffer to the first element that should be written over.
dataSizeThe number of bytes to be written over.
dataA pointer to the data.
Here is the call graph for this function:
Here is the caller graph for this function:

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