cgv
Loading...
Searching...
No Matches
cgv::render::attribute_array_binding Class Reference

the attribute_array_binding allows to define vertex attributes (i.e. More...

#include <attribute_array_binding.h>

Inheritance diagram for cgv::render::attribute_array_binding:
cgv::render::attribute_array_binding_base cgv::render::render_component

static interface is used to access global attribute arrays of context

static bool is_global_array_enabled (const context &ctx, int loc)
 check whether an attribute array is enabled
 
static bool enable_global_array (const context &ctx, int loc)
 enable attribute array of given location
 
static bool disable_global_array (const context &ctx, int loc)
 disable attribute array of given location
 
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 case of success also enable vertex attribute array
 
template<typename T >
static bool set_global_attribute_array (const context &ctx, int loc, const T &array)
 point array of vertex attribute at location loc to array array stored in CPU memory; in case of success also enable vertex attribute array
 
template<typename T >
static bool set_global_attribute_array (const context &ctx, int loc, const T *array_ptr, size_t nr_elements, unsigned stride=0)
 point array of vertex attribute at location loc to array with nr_elements elements pointed to by array_ptr in CPU memory; in case of success also enable vertex attribute array
 
static bool set_global_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=0)
 point array of vertex attribute at location loc to elements of given type in vertex buffer object at given offset spaced with given stride; in case of success also enable vertex attribute array
 
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
 
 attribute_array_binding ()
 default constructor does not create attribute array binding
 
 ~attribute_array_binding ()
 destruct 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 enable (context &ctx)
 enable whole the attribute array binding object
 
bool disable (context &ctx)
 disable whole attribute array binding object
 
bool enable_array (const context &ctx, int loc)
 enable array for vertex attribute at location loc
 
bool is_array_enabled (const context &ctx, int loc) const
 check if array of vertex attribute at location loc is enabled
 
bool disable_array (const context &ctx, int loc)
 disable array for attribute at location loc
 
template<typename T >
bool set_attribute_array (const context &ctx, int loc, const T &array)
 set vertex attribute location to given array and enable array
 
template<typename T >
bool set_attribute_array (const context &ctx, int loc, const T *value_ptr, unsigned nr_elements, unsigned stride=0)
 set a vertex attribute to a single value or an array of values through the cgv::math::vec or std::vector classes.
 
bool 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=0)
 point array of vertex attribute at location loc to elements of given type in vertex buffer object at given offset spaced with given stride; in case of success also enable vertex attribute array
 
template<typename T >
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_attribute_array to set vertex attribute location to given array and enable array
 
template<typename T >
bool bind_attribute_array (const context &ctx, const shader_program &prog, const std::string &attribute_name, const T *value_ptr, unsigned nr_elements, unsigned stride=0)
 convenience function that determines attribute location in program by name and then uses set_attribute_array to set a vertex attribute to a single value or an array of values through the cgv::math::vec or std::vector classes.
 
bool bind_attribute_array (const context &ctx, const shader_program &prog, const std::string &attribute_name, type_descriptor element_type, const vertex_buffer &vbo, size_t offset_in_bytes, size_t nr_elements, unsigned stride_in_bytes=0)
 convenience function that determines attribute location in program by name and then uses set_attribute_array to point array of vertex attribute at location loc to elements of given type in vertex buffer object at given offset spaced with given stride
 
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
 

Additional Inherited Members

- Public Member Functions inherited from cgv::render::attribute_array_binding_base
 attribute_array_binding_base ()
 nothing to be done heremembers
 
- Public Member Functions inherited from cgv::render::render_component
 render_component ()
 initialize members
 
virtual bool is_created () const
 return whether component has been created
 
void put_id_void (void *ptr) const
 copy the rendering api specific id the component to the memory location of the given pointer.
 
template<typename T >
void put_id (T &id) const
 cast the refence to rendering api specific representation of component id to the specified type
 
- Public Attributes inherited from cgv::render::render_component
void * handle
 
void * internal_format
 
void * user_data
 
const contextctx_ptr
 keep pointer to my context
 
std::string last_error
 a string that contains the last error
 
- Protected Attributes inherited from cgv::render::attribute_array_binding_base
bool is_enabled
 

Detailed Description

the attribute_array_binding allows to define vertex attributes (i.e.

the inputs to the vertex shader as well as an element array that stores element indices in indexed rendering. The vertex attributes can be set from instances of std::vector, pointers to arrays and vertex_buffer objects. Each individual vertex attribute can be enabled and disabled. Each vertex attribute is attached to a program location that can be queried from a shader_program with the get_attribute_location() function. The element array can only be set to a vertex_buffer object of type VBT_INDICES with the function set_element_array().

Definition at line 19 of file attribute_array_binding.h.

Constructor & Destructor Documentation

◆ attribute_array_binding()

cgv::render::attribute_array_binding::attribute_array_binding ( )

default constructor does not create attribute array binding

create empty shader program and set the option whether errors during shader code attachment should be printed to std::cerr

Definition at line 73 of file attribute_array_binding.cxx.

◆ ~attribute_array_binding()

cgv::render::attribute_array_binding::~attribute_array_binding ( )

destruct attribute array binding object

call destruct method

Definition at line 77 of file attribute_array_binding.cxx.

References cgv::render::render_component::ctx_ptr, destruct(), and cgv::render::context::make_current().

Member Function Documentation

◆ bind_attribute_array() [1/3]

template<typename T >
bool cgv::render::attribute_array_binding::bind_attribute_array ( const context ctx,
const shader_program prog,
const std::string &  attribute_name,
const T &  array 
)
inline

convenience function that determines attribute location in program by name and then uses set_attribute_array to set vertex attribute location to given array and enable array

Definition at line 80 of file attribute_array_binding.h.

◆ bind_attribute_array() [2/3]

template<typename T >
bool cgv::render::attribute_array_binding::bind_attribute_array ( const context ctx,
const shader_program prog,
const std::string &  attribute_name,
const T *  value_ptr,
unsigned  nr_elements,
unsigned  stride = 0 
)
inline

convenience function that determines attribute location in program by name and then uses set_attribute_array to set a vertex attribute to a single value or an array of values through the cgv::math::vec or std::vector classes.

Definition at line 88 of file attribute_array_binding.h.

◆ bind_attribute_array() [3/3]

bool cgv::render::attribute_array_binding::bind_attribute_array ( const context ctx,
const shader_program prog,
const std::string &  attribute_name,
type_descriptor  element_type,
const vertex_buffer vbo,
size_t  offset_in_bytes,
size_t  nr_elements,
unsigned  stride_in_bytes = 0 
)

convenience function that determines attribute location in program by name and then uses set_attribute_array to point array of vertex attribute at location loc to elements of given type in vertex buffer object at given offset spaced with given stride

conveniance function that determines attribute location in program by name and then uses set_attribute_array to point array of vertex attribute at location loc to elements of given type in vertex buffer object at given offset spaced with given stride

Definition at line 32 of file attribute_array_binding.cxx.

References cgv::render::shader_program::get_attribute_location(), and set_attribute_array().

◆ create()

bool cgv::render::attribute_array_binding::create ( const context ctx)

create the attribute array binding object

create the attribute array binding

Definition at line 88 of file attribute_array_binding.cxx.

Referenced by cgv::render::build_render_info(), cgv::plot::plot_base::init(), cgv::render::gl::image_drawable::init(), and cgv::render::gl::gl_context::prepare_attributes().

◆ destruct()

void cgv::render::attribute_array_binding::destruct ( const context ctx)

destruct attribute array binding object

destruct attribute array

Definition at line 94 of file attribute_array_binding.cxx.

Referenced by cgv::plot::plot_base::clear(), cgv::render::gl::image_drawable::clear(), and ~attribute_array_binding().

◆ disable()

bool cgv::render::attribute_array_binding::disable ( context ctx)

disable whole attribute array binding object

disable the attribute array binding

Definition at line 111 of file attribute_array_binding.cxx.

Referenced by cgv::render::gl::image_drawable::draw(), and cgv::render::gl::gl_context::release_attributes().

◆ disable_array()

bool cgv::render::attribute_array_binding::disable_array ( const context ctx,
int  loc 
)

◆ disable_global_array()

bool cgv::render::attribute_array_binding::disable_global_array ( const context ctx,
int  loc 
)
static

◆ enable()

bool cgv::render::attribute_array_binding::enable ( context ctx)

enable whole the attribute array binding object

enable the attribute array binding

Definition at line 101 of file attribute_array_binding.cxx.

References cgv::render::context::error(), and cgv::render::render_component::is_created().

Referenced by cgv::render::gl::image_drawable::draw(), and cgv::render::gl::gl_context::prepare_attributes().

◆ enable_array()

bool cgv::render::attribute_array_binding::enable_array ( const context ctx,
int  loc 
)

enable array for vertex attribute at location loc

Definition at line 117 of file attribute_array_binding.cxx.

Referenced by cgv::plot::plot_base::init(), cgv::render::gl::image_drawable::init(), and cgv::render::gl::gl_context::prepare_attributes().

◆ enable_global_array()

bool cgv::render::attribute_array_binding::enable_global_array ( const context ctx,
int  loc 
)
static

◆ is_array_enabled()

bool cgv::render::attribute_array_binding::is_array_enabled ( const context ctx,
int  loc 
) const

check if array of vertex attribute at location loc is enabled

Definition at line 122 of file attribute_array_binding.cxx.

Referenced by cgv::render::attribute_array_manager::has_attribute().

◆ is_global_array_enabled()

bool cgv::render::attribute_array_binding::is_global_array_enabled ( const context ctx,
int  loc 
)
static

check whether an attribute array is enabled

Definition at line 47 of file attribute_array_binding.cxx.

◆ set_attribute_array() [1/3]

template<typename T >
bool cgv::render::attribute_array_binding::set_attribute_array ( const context ctx,
int  loc,
const T &  array 
)
inline

◆ set_attribute_array() [2/3]

template<typename T >
bool cgv::render::attribute_array_binding::set_attribute_array ( const context ctx,
int  loc,
const T *  value_ptr,
unsigned  nr_elements,
unsigned  stride = 0 
)
inline

set a vertex attribute to a single value or an array of values through the cgv::math::vec or std::vector classes.

Definition at line 73 of file attribute_array_binding.h.

◆ set_attribute_array() [3/3]

bool cgv::render::attribute_array_binding::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 = 0 
)

point array of vertex attribute at location loc to elements of given type in vertex buffer object at given offset spaced with given stride; in case of success also enable vertex attribute array

Definition at line 21 of file attribute_array_binding.cxx.

◆ set_element_array()

bool cgv::render::attribute_array_binding::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

Definition at line 41 of file attribute_array_binding.cxx.

◆ set_global_attribute_array() [1/4]

template<typename T >
static bool cgv::render::attribute_array_binding::set_global_attribute_array ( const context ctx,
int  loc,
const T &  array 
)
inlinestatic

point array of vertex attribute at location loc to array array stored in CPU memory; in case of success also enable vertex attribute array

Definition at line 35 of file attribute_array_binding.h.

◆ set_global_attribute_array() [2/4]

template<typename T >
static bool cgv::render::attribute_array_binding::set_global_attribute_array ( const context ctx,
int  loc,
const T *  array_ptr,
size_t  nr_elements,
unsigned  stride = 0 
)
inlinestatic

point array of vertex attribute at location loc to array with nr_elements elements pointed to by array_ptr in CPU memory; in case of success also enable vertex attribute array

Definition at line 40 of file attribute_array_binding.h.

◆ set_global_attribute_array() [3/4]

bool cgv::render::attribute_array_binding::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 
)
static

point array of vertex attribute at location loc to vertex buffer array array stored in CPU memory; in case of success also enable vertex attribute array

Definition at line 64 of file attribute_array_binding.cxx.

Referenced by cgv::render::gl::cover_screen(), vr_test::draw(), cgv::render::gl::image_drawable::draw(), and vr_view_interactor::draw_action_zone().

◆ set_global_attribute_array() [4/4]

bool cgv::render::attribute_array_binding::set_global_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 = 0 
)
static

point array of vertex attribute at location loc to elements of given type in vertex buffer object at given offset spaced with given stride; in case of success also enable vertex attribute array

Definition at line 9 of file attribute_array_binding.cxx.

◆ set_global_element_array()

bool cgv::render::attribute_array_binding::set_global_element_array ( const context ctx,
const vertex_buffer vbe 
)
static

set the global elment array to the given vertex buffer object which must me of type VBT_INDICES

Definition at line 15 of file attribute_array_binding.cxx.


The documentation for this class was generated from the following files: