![]() |
AireEngine
A 3D Open-World Game Engine
|
#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 | |
| Buffer & | operator= (const Buffer &)=delete |
A wrapper over an OpenGL buffer. Used to simplify buffer setup and to provide automatic clean-up.
| 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
| bufferSize | The size of the buffer to be allocated. Cannot be changed later. |
| data | A pointer to the data to be copied to the buffer. nullptr if data is not available yet. |
| flags | Flags used for buffer creation. Default one is GL_DYNAMIC_STORAGE_BIT. |
|
inline |
Bind the buffer to an atomic counter binding point.
| index | The uniform binding point to bind to. |
| offset | Offset within the buffer where the memory to be bound begins (in case only a subset of the buffer will be bound). |
| size | Size of the memory block to be bound (in bytes). |
| void Buffer::bindElementBuffer | ( | const VertexArrayObject & | vao | ) |
Bind the buffer as an element buffer holding faces that index into the vertex array.
| vao | The vertex array object. |

|
inline |
Bind the buffer to a shader storage binding point.
| index | The shader storage binding point to bind to. |
| offset | Offset within the buffer where the memory to be bound begins (in case only a subset of the buffer will be bound). |
| size | Size of the memory block to be bound (in bytes). |
|
inline |
Bind the buffer to a transform feedback binding point.
| index | The transform feedback binding point to bind to. |
| offset | Offset within the buffer where the memory to be bound begins (in case only a subset of the buffer will be bound). |
| size | Size of the memory block to be bound (in bytes). |
| void Buffer::bindUniform | ( | GLuint | index, |
| GLintptr | offset, | ||
| GLsizeiptr | size ) |
Bind the buffer to a uniform binding point.
| index | The uniform binding point to bind to. |
| offset | Offset 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. |
| size | Size of the memory block to be bound (in bytes). |
| void Buffer::bindVertAttrib | ( | const VertexArrayObject & | vao, |
| GLuint | bindingPoint, | ||
| GLintptr | offset, | ||
| GLsizei | stride ) |
Bind the buffer to a vertex attribute binding point.
| vao | The vertex array object holding attribute specification. |
| bindingPoint | The binding point of the attribute. We often set it to simply be the same as the attribute index. |
| offset | Offset within the buffer where the attribute memory begins. |
| stride | Number of bytes from the start where the next attribute is stored. Allows interleaved attributes. |

|
inline |
| GLint64 Buffer::getSize | ( | ) | const |

| void Buffer::setData | ( | GLintptr | offset, |
| GLsizeiptr | dataSize, | ||
| const void * | data ) |
Set data for (a part of) the buffer.
| offset | The offset in the buffer to the first element that should be written over. |
| dataSize | The number of bytes to be written over. |
| data | A pointer to the data. |

