SenOGL
0.2
Library aiming to ease the use of OpenGL
|
#include <Buffer.hpp>
Public Types | |
enum | Target : GLenum { Target::VertexAttributes = GL_ARRAY_BUFFER, Target::AtomicCounter = GL_ATOMIC_COUNTER_BUFFER, Target::CopyRead = GL_COPY_READ_BUFFER, Target::CopyWrite = GL_COPY_WRITE_BUFFER, Target::IndirectDispatch = GL_DISPATCH_INDIRECT_BUFFER, Target::IndirectDraw = GL_DRAW_INDIRECT_BUFFER, Target::VertexIndices = GL_ELEMENT_ARRAY_BUFFER, Target::PixelPack = GL_PIXEL_PACK_BUFFER, Target::PixelUnpack = GL_PIXEL_UNPACK_BUFFER, Target::Query = GL_QUERY_BUFFER, Target::ShaderStorage = GL_SHADER_STORAGE_BUFFER, Target::Texture = GL_TEXTURE_BUFFER, Target::TransformFeedback = GL_TRANSFORM_FEEDBACK_BUFFER, Target::Uniform = GL_UNIFORM_BUFFER } |
Bind targets. More... | |
enum | Usage : GLenum { Usage::StaticDraw = GL_STATIC_DRAW, Usage::StaticRead = GL_STATIC_READ, Usage::StaticCopy = GL_STATIC_COPY, Usage::DynamicDraw = GL_DYNAMIC_DRAW, Usage::DynamicRead = GL_DYNAMIC_READ, Usage::DynamicCopy = GL_DYNAMIC_COPY, Usage::StreamDraw = GL_STREAM_DRAW, Usage::StreamRead = GL_STREAM_READ, Usage::StreamCopy = GL_STREAM_COPY } |
Usage hint for mutable buffers. More... | |
enum | StorageUsage : GLbitfield { StorageUsage::Unspecified = 0, StorageUsage::DynamicStorageBit = GL_DYNAMIC_STORAGE_BIT, StorageUsage::MapReadBit = GL_MAP_READ_BIT, StorageUsage::MapWriteBit = GL_MAP_WRITE_BIT, StorageUsage::MapPersistentBit = GL_MAP_PERSISTENT_BIT, StorageUsage::MapCoherentBit = GL_MAP_COHERENT_BIT, StorageUsage::ClientStorageBit = GL_CLIENT_STORAGE_BIT } |
Usage hint for immutable buffers. More... | |
Public Member Functions | |
Buffer ()=default | |
Default Constructor Avoid using this is favor of the 'typed' constructor when possible. More... | |
Buffer (Target type, GLuint handle=0) | |
Constructor specifying a buffer type. More... | |
Buffer (const Buffer &)=default | |
Copy constructor. More... | |
Buffer (Buffer &&)=default | |
Move constructor. More... | |
Buffer & | operator= (const Buffer &)=default |
Assigment operator. More... | |
Buffer & | operator= (Buffer &&)=default |
Move assignment operator. More... | |
virtual | ~Buffer () |
Destructor. More... | |
virtual void | init () override |
Generates a new buffer name to manage. More... | |
void | init (Target t) |
Generates a new buffer of type t. More... | |
virtual void | cleanup () override |
Destroy managed buffer. More... | |
void | bind () const |
Binds the buffer to its assigned target (type) More... | |
void | bind (Target t) const |
Binds the buffer to arbitrary target (type) More... | |
void | bind (GLuint bindingPoint, GLintptr offset=0, GLsizeiptr size=0) const |
Bind this buffer to the specified binding point in the OpenGL context. More... | |
void | bind (Target target, GLuint bindingPoint, GLintptr offset=0, GLsizeiptr size=0) const |
Similar to bind(GLuint, GLintptr, GLsizeiptr) but allowing for another target than the type of the buffer. More... | |
void | unbind () const |
Unbinds the buffer. More... | |
void | data (const void *data, size_t size, Buffer::Usage usage) const |
glBufferData More... | |
void | store (const void *data, size_t size, Buffer::StorageUsage flags) const |
glBufferStorage More... | |
void | subData (size_t offset, size_t size, const void *data) const |
glBufferSubData More... | |
Target | getType () const |
void | setType (Target t) |
If the type wasn't specified at creation, this should be called before any init() More... | |
Public Member Functions inherited from OpenGLObject | |
OpenGLObject () | |
OpenGLObject (GLuint handle) | |
Constructs a instance managing an existing OpenGL Object. More... | |
OpenGLObject (const OpenGLObject &)=default | |
OpenGLObject (OpenGLObject &&)=default | |
OpenGLObject & | operator= (const OpenGLObject &)=default |
OpenGLObject & | operator= (OpenGLObject &&)=default |
virtual | ~OpenGLObject () |
GLuint | getName () const |
Returns OpenGL name of the object. More... | |
void | setName (GLuint n) |
Sets the OpenGL name of the object managed by this instance /!\ Use with caution ! (assignment operator is probably what you're looking for) More... | |
virtual bool | isValid () const |
Returns true if the object seems valid. More... | |
operator bool () const | |
Syntactic sugar for isValid(). More... | |
Static Public Member Functions | |
static void | copySubData (Target srcType, Target dstType, GLuint srcOffset, GLuint dstOffset, GLuint size) |
glCopyBufferSubData More... | |
static void | copySubData (const Buffer &src, const Buffer &dst, GLuint srcOffset, GLuint dstOffset, GLuint size) |
glCopyNamedBufferSubData More... | |
Protected Attributes | |
Target | _type = Target::VertexAttributes |
Target of the Buffer. More... | |
Protected Attributes inherited from OpenGLObject | |
GLuint | _handle |
OpenGL name of the managed object. More... | |
OpenGL Buffer Object.
|
strong |
Usage hint for immutable buffers.
|
strong |
Bind targets.
Enumerator | |
---|---|
VertexAttributes |
Vertex attributes (VBO) |
AtomicCounter |
Atomic counter storage. |
CopyRead |
Buffer copy source. |
CopyWrite |
Buffer copy destination. |
IndirectDispatch |
Indirect compute dispatch commands. |
IndirectDraw |
Indirect command arguments. |
VertexIndices |
Vertex array indices (IBO) |
PixelPack |
Pixel read target. |
PixelUnpack |
Texture data source. |
Query |
Query result buffer. |
ShaderStorage |
Read-write storage for shaders. |
Texture |
Texture data buffer. |
TransformFeedback |
Transform feedback buffer. |
Uniform |
Uniform block storage (UBO) |
|
strong |
Usage hint for mutable buffers.
STATIC: The user will set the data once. DYNAMIC: The user will set the data occasionally. STREAM: The user will be changing the data after every use. Or almost every use.
DRAW: The user will be writing data to the buffer, but the user will not read it. READ: The user will not be writing data, but the user will be reading it back. COPY: The user will be neither writing nor reading the data.
|
default |
Buffer::Buffer | ( | Target | type, |
GLuint | handle = 0 |
||
) |
Constructor specifying a buffer type.
type | Target |
handle | Raw OpenGL name (Used to manage a existing object, call init() to generate a new one). |
|
default |
Copy constructor.
|
default |
Move constructor.
|
virtual |
Destructor.
void Buffer::bind | ( | ) | const |
Binds the buffer to its assigned target (type)
void Buffer::bind | ( | GLuint | bindingPoint, |
GLintptr | offset = 0 , |
||
GLsizeiptr | size = 0 |
||
) | const |
Bind this buffer to the specified binding point in the OpenGL context.
Buffer type must be AtomicCounter, TransformFeedback, Uniform or ShaderStorage.
bindingPoint | Binding Point |
offset | Starting offset in basic machine unit (optional, default: 0) |
size | Amount of data in machine unit to bind (optional, default: 0, means the entire buffer) |
void Buffer::bind | ( | Target | target, |
GLuint | bindingPoint, | ||
GLintptr | offset = 0 , |
||
GLsizeiptr | size = 0 |
||
) | const |
Similar to bind(GLuint, GLintptr, GLsizeiptr) but allowing for another target than the type of the buffer.
target | Target of bind operation. Must be AtomicCounter, TransformFeedback, Uniform or ShaderStorage. |
bindingPoint | Binding Point |
offset | Starting offset in basic machine unit (optional, default: 0) |
size | Amount of data in machine unit to bind (optional, default: 0, means the entire buffer) |
|
overridevirtual |
Destroy managed buffer.
Implements OpenGLObject.
|
inlinestatic |
glCopyBufferSubData
srcType | Source buffer type |
dstType | Destination buffer type |
srcOffset | Source offset (in basic machine unit) |
dstOffset | Source offset (in basic machine unit) |
size | Data size to copy (in basic machine unit) |
|
inlinestatic |
glCopyNamedBufferSubData
src | Source buffer |
dst | Destination buffer |
srcOffset | Source offset (in basic machine unit) |
dstOffset | Source offset (in basic machine unit) |
size | Data size to copy (in basic machine unit) |
void Buffer::data | ( | const void * | data, |
size_t | size, | ||
Buffer::Usage | usage | ||
) | const |
glBufferData
|
inline |
|
overridevirtual |
Generates a new buffer name to manage.
Implements OpenGLObject.
void Buffer::init | ( | Target | t | ) |
Generates a new buffer of type t.
t | Target of the new buffer |
|
inline |
void Buffer::store | ( | const void * | data, |
size_t | size, | ||
Buffer::StorageUsage | flags | ||
) | const |
glBufferStorage
void Buffer::subData | ( | size_t | offset, |
size_t | size, | ||
const void * | data | ||
) | const |
glBufferSubData
void Buffer::unbind | ( | ) | const |
Unbinds the buffer.
|
protected |
Target of the Buffer.