1#include "vertex_buffer.h"
32 ctx.vertex_buffer_bind(*
this, _type ==
VBT_UNDEF ? this->
type : _type);
37 ctx.vertex_buffer_unbind(*
this, _type ==
VBT_UNDEF ? this->
type : _type);
44 ctx.vertex_buffer_unbind(*
this,
type, index);
49 ctx.vertex_buffer_bind(*
this, this->
type, index);
54 ctx.vertex_buffer_bind(*
this, _type, index);
60 size_in_bytes = _size_in_bytes;
61 return ctx.vertex_buffer_create(*
this, 0, size_in_bytes);
71 this->size_in_bytes = size_in_bytes;
72 return ctx.vertex_buffer_resize(*
this, 0, size_in_bytes);
82 return ctx.vertex_buffer_copy(*
this, src_offset_in_bytes, dst, dst_offset_in_bytes, size_in_bytes);
89 ctx.vertex_buffer_destruct(*
this);
base class for all drawables, which is independent of the used rendering API.
virtual bool make_current() const =0
make the current context current if possible
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
a vertex buffer is an unstructured memory block on the GPU.
void bind(context &ctx, VertexBufferType type=VBT_UNDEF) const
Bind buffer to appropriate target.
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 from description of component format, where the default format specifies a color buffer wit...
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
void unbind(context &ctx, VertexBufferType type=VBT_UNDEF) const
Unbind buffer from the appropriate target.
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.
bool is_created() const override
Check whether the vertex buffer has been created.
void destruct(const context &ctx)
destruct the render buffer
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.