1#include <cgv/base/base.h>
2#include "attribute_array_binding.h"
3#include "shader_program.h"
4#include <cgv/render/vertex_buffer.h>
11 return ctx.set_attribute_array_void(0, loc, element_type, &vbo,
reinterpret_cast<const void*
>(offset_in_bytes), nr_elements, stride_in_bytes);
17 return ctx.set_element_array(0, &vbe);
23 return ctx.set_attribute_array_void(
this, loc, element_type, &vbo,
reinterpret_cast<const void*
>(offset_in_bytes), nr_elements, stride_in_bytes);
26int attribute_array_binding::get_attribute_location(
const context& ctx,
const shader_program& prog,
const std::string& attr_name)
const
37 return set_attribute_array(ctx, loc, element_type, vbo, offset_in_bytes, nr_elements, stride_in_bytes);
43 return ctx.set_element_array(
this, &vbe);
49 return ctx.is_attribute_array_enabled(0, loc);
55 return ctx.enable_attribute_array(0, loc,
true);
60 return ctx.enable_attribute_array(0, loc,
false);
67 reinterpret_cast<size_t&
>(ptr) = offset;
68 return ctx.set_attribute_array_void(0, loc, td, &vbo, ptr, size, stride);
90 return ctx.attribute_array_binding_create(*
this);
97 ctx.attribute_array_binding_destruct(*
this);
104 ctx.
error(
"attribute_array_binding::enable() attribute array binding must be created before enable",
this);
107 return ctx.attribute_array_binding_enable(*
this);
113 return ctx.attribute_array_binding_disable(*
this);
119 return ctx.enable_attribute_array(
this, loc,
true);
126 return ctx.is_attribute_array_enabled(
this, loc);
131 return ctx.enable_attribute_array(
this, loc,
false);
bool set_element_array(const context &ctx, const vertex_buffer &vbe)
set the elment array to the given vertex buffer object which must me of type VBT_INDICES
bool enable(context &ctx)
enable whole the attribute array binding object
static bool enable_global_array(const context &ctx, int loc)
enable attribute array of given location
bool create(const context &ctx)
create the attribute array binding object
void destruct(const context &ctx)
destruct attribute array binding object
static bool set_global_attribute_array(const context &ctx, int loc, const vertex_buffer &vbo, type_descriptor td, size_t size, size_t offset, unsigned stride=0)
point array of vertex attribute at location loc to vertex buffer array array stored in CPU memory; in...
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
static bool is_global_array_enabled(const context &ctx, int loc)
check whether an attribute array is enabled
static bool set_global_element_array(const context &ctx, const vertex_buffer &vbe)
set the global elment array to the given vertex buffer object which must me of type VBT_INDICES
static bool disable_global_array(const context &ctx, int loc)
disable attribute array of given location
~attribute_array_binding()
destruct attribute array binding object
bool enable_array(const context &ctx, int loc)
enable array for vertex attribute at location loc
bool disable_array(const context &ctx, int loc)
disable array for attribute at location loc
bool bind_attribute_array(const context &ctx, const shader_program &prog, const std::string &attribute_name, const T &array)
convenience function that determines attribute location in program by name and then uses set_attribut...
bool set_attribute_array(const context &ctx, int loc, const T &array)
set vertex attribute location to given array and enable array
attribute_array_binding()
default constructor does not create attribute array binding
base class for all drawables, which is independent of the used rendering API.
virtual void error(const std::string &message, const render_component *rc=0) const
error handling
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 shader program combines several shader code fragments to a complete definition of the shading pipel...
int get_attribute_location(const context &ctx, const std::string &name) const
query location index of an attribute
a vertex buffer is an unstructured memory block on the GPU.
compact type description of data that can be sent to the context; convertible to int