1#include "attribute_array_manager.h"
16bool attribute_array_manager::set_attribute_array(
const context& ctx,
int loc,
type_descriptor element_type,
const vertex_buffer& vbo,
size_t offset_in_bytes,
size_t nr_elements,
unsigned stride_in_bytes) {
17 return ctx.set_attribute_array_void(&
aab, loc, element_type, &vbo,
reinterpret_cast<const void*
>(offset_in_bytes), nr_elements, stride_in_bytes);
21 auto iter =
vbos.find(-1);
22 if(iter ==
vbos.end())
24 return iter->second != 0;
27void attribute_array_manager::remove_indices(
const context& ctx) {
35void attribute_array_manager::remove_attribute_array(
const context& ctx,
int loc) {
36 vertex_buffer*& vbo_ptr =
vbos[loc];
41 ctx.enable_attribute_array(&
aab, loc,
false);
44bool attribute_array_manager::is_created()
const {
47bool attribute_array_manager::init(context& ctx) {
50bool attribute_array_manager::enable(context& ctx) {
53bool attribute_array_manager::disable(context& ctx) {
57void attribute_array_manager::destruct(
const context& ctx) {
60 p.second->destruct(ctx);
bool enable(context &ctx)
enable whole the attribute array binding object
bool create(const context &ctx)
create the attribute array binding object
void destruct(const context &ctx)
destruct attribute array binding object
bool disable(context &ctx)
disable whole attribute array binding object
bool is_array_enabled(const context &ctx, int loc) const
check if array of vertex attribute at location loc is enabled
std::map< int, vertex_buffer * > vbos
store vertex buffers generated per attribute location
attribute_array_manager(VertexBufferUsage _default_usage=VBU_STREAM_DRAW)
default initialization
bool has_index_buffer() const
whether aam contains an index buffer
bool has_attribute(const context &ctx, int loc) const
check whether the given attribute is available
attribute_array_binding aab
attribue array binding used to store array pointers
~attribute_array_manager()
destructor calls destruct
VertexBufferUsage default_usage
store default buffer usage
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
virtual bool is_created() const
return whether component has been created
const context * ctx_ptr
keep pointer to my context
a vertex buffer is an unstructured memory block on the GPU.
void destruct(const context &ctx)
destruct the render buffer
VertexBufferUsage
Provides vertex buffer usage hints as defined in OpenGL.
compact type description of data that can be sent to the context; convertible to int