1#include "vertex_buffer.h"
41 ctx.vertex_buffer_unbind(*
this,
type, index);
46 ctx.vertex_buffer_bind(*
this, this->
type, index);
51 ctx.vertex_buffer_bind(*
this,
type, index);
56 this->size_in_bytes = size_in_bytes;
57 return ctx.vertex_buffer_create(*
this, 0, size_in_bytes);
62 return handle !=
nullptr;
67 if(this->size_in_bytes != size_in_bytes) {
68 this->size_in_bytes = size_in_bytes;
69 return ctx.vertex_buffer_resize(*
this, 0, size_in_bytes);
81 return ctx.vertex_buffer_copy(*
this, src_offset_in_bytes, dst, dst_offset_in_bytes, size_in_bytes);
87 ctx.vertex_buffer_destruct(*
this);
base class for all drawables, which is independent of the used rendering API.
const context * ctx_ptr
keep pointer to my context
VertexBufferType type
buffer type defaults to VBT_VERTICES
VertexBufferUsage usage
usage defaults to VBU_STATIC_DRAW
size_t get_size_in_bytes() const
Retrieves the current size of the buffer in bytes.
vertex_buffer(VertexBufferType type=VBT_VERTICES, VertexBufferUsage usage=VBU_STATIC_DRAW)
Construct a vertex buffer of the given type and usage.
bool create_or_resize(const context &ctx, size_t size_in_bytes)
Convenience wrapper to either create() or resize() the buffer.
bool resize(const context &ctx, size_t size_in_bytes)
resize vertex buffer to size size given in bytes clearing all data
~vertex_buffer()
calls the destruct method if necessary
bool create(const context &ctx, size_t size_in_bytes)
create empty vertex buffer of size size given in bytes
bool copy(const context &ctx, size_t src_offset_in_bytes, size_t size_in_bytes, vertex_buffer &dst, size_t dst_offset_in_bytes) const
Copy bytes between different vertex_buffer instances.
void unbind(const context &ctx, VertexBufferType type=VBT_UNDEF) const
Unbind buffer from the appropriate target.
bool is_created() const override
Check whether the vertex buffer has been created.
void destruct(const context &ctx)
destruct the render buffer
void bind(const context &ctx, VertexBufferType type=VBT_UNDEF) const
Bind buffer to appropriate target.
namespace for api independent GPU programming
VertexBufferUsage
Provides vertex buffer usage hints as defined in OpenGL.
VertexBufferType
Provides vertex buffer types to allow implicit binding.
@ VBT_UNDEF
The buffer has no type.
this header is dependency free