cgv
|
renderer that supports point splatting More...
#include <slab_renderer.h>
Public Member Functions | |
slab_renderer () | |
initializes position_is_center to true | |
void | enable_attribute_array_manager (const context &ctx, attribute_array_manager &aam) |
call this before setting attribute arrays to manage attribute array in given manager | |
void | disable_attribute_array_manager (const context &ctx, attribute_array_manager &aam) |
call this after last render/draw call to ensure that no other users of renderer change attribute arrays of given manager | |
void | set_position_is_center (bool _position_is_center) |
set the flag, whether the position is interpreted as the slab center, true by default | |
bool | enable (context &ctx) |
overload to activate group style | |
template<typename T > | |
void | set_extent (const context &ctx, const T &extent) |
specify a single extent for all slabs | |
template<typename T > | |
void | set_extent_array (const context &ctx, const std::vector< T > &extents) |
extent array specifies slab extends in case of position_is_center=true, otherwise the maximum point of each slab | |
template<typename T > | |
void | set_extent_array (const context &ctx, const T *extents, size_t nr_elements, unsigned stride_in_bytes=0) |
extent array specifies slab extends in case of position_is_center=true, otherwise the maximum point of each slab | |
template<typename T > | |
void | set_box_array (const context &ctx, const std::vector< cgv::media::axis_aligned_box< T, 3 > > &box) |
specify box array directly. This sets position_is_center to false as well as position and extent array | |
template<typename T > | |
void | set_box_array (const context &ctx, const cgv::media::axis_aligned_box< T, 3 > *box, size_t count) |
specify box array directly. This sets position_is_center to false as well as position and extent array | |
template<typename T > | |
void | set_translation_array (const context &ctx, const std::vector< T > &translations) |
template method to set the translations from a vector of vectors of type T, which should have 3 components | |
template<typename T > | |
void | set_translation_array (const context &ctx, const T *translations, size_t nr_elements, unsigned stride) |
template method to set the translations from a vector of vectors of type T, which should have 3 components | |
template<typename T > | |
void | set_rotation_array (const context &ctx, const std::vector< T > &rotations) |
template method to set the rotation from a vector of quaternions of type T, which should have 4 components | |
template<typename T > | |
void | set_rotation_array (const context &ctx, const T *rotations, size_t nr_elements, unsigned stride) |
template method to set the rotation from a vector of quaternions of type T, which should have 4 components | |
template<typename T > | |
void | set_texture_index_array (const context &ctx, const std::vector< T > &texture_indices) |
extent array specifies slab extends in case of position_is_center=true, otherwise the maximum point of each slab | |
template<typename T > | |
void | set_texture_index_array (const context &ctx, const T *texture_indices, size_t nr_elements, unsigned stride_in_bytes=0) |
extent array specifies slab extends in case of position_is_center=true, otherwise the maximum point of each slab | |
bool | validate_attributes (const context &ctx) const |
check additionally the group attributes | |
bool | disable (context &ctx) |
disable renderer | |
void | draw (context &ctx, size_t start, size_t count, bool use_strips=false, bool use_adjacency=false, uint32_t strip_restart_index=-1) |
Draw a range of vertices or indexed elements. | |
![]() | |
void | set_group_index_array (const context &ctx, const std::vector< unsigned > &group_indices) |
method to set the group index attribute | |
void | set_group_index_array (const context &ctx, const unsigned *group_indices, size_t nr_elements) |
method to set the group index attribute | |
void | set_group_index_array (const context &ctx, type_descriptor element_type, const vertex_buffer &vbo, size_t offset_in_bytes, size_t nr_elements, unsigned stride_in_bytes=0) |
method to set the group index attribute from a vertex buffer object, the element type must be given as explicit template parameter | |
template<typename T > | |
void | set_group_index_array (const context &ctx, const vertex_buffer &vbo, size_t offset_in_bytes, size_t nr_elements, unsigned stride_in_bytes=0) |
template method to set the group index color attribute from a vertex buffer object, the element type must be given as explicit template parameter | |
void | remove_group_index_array (const context &ctx) |
remove the group index attribute | |
template<typename T > | |
void | set_group_colors (const context &ctx, const std::vector< T > &colors) |
template method to set the group colors from a vector of colors of type T | |
template<typename T > | |
void | set_group_colors (const context &ctx, const T *colors, size_t nr_elements) |
template method to set the group colors from a vector of colors of type T | |
template<typename T > | |
void | set_group_translations (const context &ctx, const std::vector< T > &group_translations) |
template method to set the group translations from a vector of vectors of type T, which should have 3 components | |
template<typename T > | |
void | set_group_translations (const context &ctx, const T *group_translations, size_t nr_elements) |
template method to set the group translations from a vector of vectors of type T, which should have 3 components | |
template<typename T > | |
void | set_group_rotations (const context &ctx, const std::vector< T > &group_rotations) |
template method to set the group rotation from a vector of quaternions of type T, which should have 4 components | |
template<typename T > | |
void | set_group_rotations (const context &ctx, const T *group_rotations, size_t nr_elements) |
template method to set the group rotation from a vector of quaternions of type T, which should have 4 components | |
![]() | |
shader_define_map & | ref_defines () |
access to shader define map to update defines not handled by render style | |
shader_program & | ref_prog () |
derived renderer classes have access to shader program | |
void | set_prog (shader_program &one_shot_prog) |
set external shader program up to next call to disable() or render() | |
void | draw_impl (context &ctx, PrimitiveType pt, size_t start, size_t count, bool use_strips=false, bool use_adjacency=false, uint32_t strip_restart_index=-1) |
default implementation of draw method with support for indexed rendering and different primitive types | |
void | draw_impl_instanced (context &ctx, PrimitiveType type, size_t start, size_t count, size_t instance_count, bool use_strips=false, bool use_adjacency=false, uint32_t strip_restart_index=-1) |
default implementation of instanced draw method with support for indexed rendering and different primitive types | |
renderer () | |
construct and init attribute tracking flags | |
virtual | ~renderer () |
destructor deletes default renderer style | |
void | manage_singleton (context &ctx, const std::string &renderer_name, int &ref_count, int ref_count_change) |
used by derived classes to manage singletons | |
virtual void | set_attribute_array_manager (const context &ctx, attribute_array_manager *_aam_ptr=0) |
this function is deprecated, please use enable_attribute_array_manager() and disable_attribute_manager() instead | |
void | set_render_style (const render_style &rs) |
reference given render style | |
bool | build_program (context &ctx, shader_program &prog, const render_style &rs) |
build shader program for specific render style | |
virtual bool | init (context &ctx) |
call init() once before using renderer | |
template<typename T > | |
void | set_position (const context &ctx, const T &position) |
templated method to set the position attribute from a single position of type T | |
template<typename T > | |
void | set_position_array (const context &ctx, const std::vector< T > &positions) |
templated method to set the position attribute from a vector of positions of type T | |
template<typename T > | |
void | set_position_array (const context &ctx, const T *positions, size_t nr_elements, unsigned stride_in_bytes=0) |
templated method to set the position attribute from a vector of positions of type T | |
void | set_position_array (const context &ctx, type_descriptor element_type, const vertex_buffer &vbo, size_t offset_in_bytes, size_t nr_elements, unsigned stride_in_bytes) |
method to set the position attribute from a vertex buffer object | |
template<typename T > | |
void | set_position_array (const context &ctx, const vertex_buffer &vbo, size_t offset_in_bytes, size_t nr_elements, unsigned stride_in_bytes=0) |
template method to set the position attribute from a vertex buffer object, the element type must be given as explicit template parameter | |
void | remove_position_array (const context &ctx) |
remove the position attribute | |
template<typename T > | |
void | set_color (const context &ctx, const T &color) |
templated method to set the color attribute from a single color of type T | |
template<typename T > | |
void | set_color_array (const context &ctx, const std::vector< T > &colors) |
template method to set the color attribute from a vector of colors of type T | |
template<typename T > | |
void | set_color_array (const context &ctx, const T *colors, size_t nr_elements, unsigned stride_in_bytes=0) |
template method to set the color attribute from a vector of colors of type T | |
void | set_color_array (const context &ctx, type_descriptor element_type, const vertex_buffer &vbo, size_t offset_in_bytes, size_t nr_elements, unsigned stride_in_bytes=0) |
method to set the color attribute from a vertex buffer object, the element type must be given as explicit template parameter | |
template<typename T > | |
void | set_color_array (const context &ctx, const vertex_buffer &vbo, size_t offset_in_bytes, size_t nr_elements, unsigned stride_in_bytes=0) |
template method to set the color attribute from a vertex buffer object, the element type must be given as explicit template parameter | |
void | remove_color_array (const context &ctx) |
remove the color attribute | |
template<typename T > | |
bool | set_indices (const context &ctx, const std::vector< T > &indices, bool keep_on_cpu=false) |
Set the indices for indexed rendering from a vector. | |
template<typename T > | |
bool | set_indices (const context &ctx, const T *indices, size_t nr_indices, bool keep_on_cpu=false) |
Set the indices for indexed rendering from an array given as a pointer. | |
template<typename T > | |
bool | set_indices (const context &ctx, const vertex_buffer &vbo, size_t count) |
Set the indices for indexed rendering from a GPU buffer. | |
bool | has_indices () const |
return whether indices have been defined | |
void | remove_indices (const context &ctx) |
remove previously set indices | |
const vertex_buffer * | get_vertex_buffer_ptr (const context &ctx, const attribute_array_manager &aam, const std::string &attr_name) |
const vertex_buffer * | get_index_buffer_ptr (const attribute_array_manager &aam) |
bool | validate_and_enable (context &ctx) |
validate attributes and if successful, enable renderer | |
virtual bool | render (context &ctx, size_t start, size_t count, bool use_strips=false, bool use_adjacency=false, uint32_t strip_restart_index=-1) |
Convenience function that draws vertex or indexed element with this renderer. | |
virtual void | clear (const context &ctx) |
the clear function destructs the shader program | |
Protected Member Functions | |
render_style * | create_render_style () const |
overload to allow instantiation of box_renderer | |
bool | build_shader_program (context &ctx, shader_program &prog, const shader_define_map &defines) |
build slab program | |
![]() | |
bool | has_aam () const |
check for attribute array manager | |
bool | has_attribute (const context &ctx, const std::string &name) |
check for attribute | |
const render_style * | get_style_ptr () const |
access to render style | |
bool | attributes_persist () const |
return whether attributes persist after a call to disable | |
virtual void | update_defines (shader_define_map &defines) |
overload to update the shader defines based on the current render style; only called if internal shader program is used | |
template<typename T > | |
const T & | get_style () const |
access to style | |
int | get_prog_attribute_location (const context &ctx, const std::string &name, bool error_check=true) |
template<typename T > | |
bool | set_attribute_array (const context &ctx, const std::string &name, const T &array) |
template<typename T > | |
bool | set_attribute_array (const context &ctx, const std::string &name, const T *array_ptr, size_t nr_elements, unsigned stride) |
bool | set_attribute_array (const context &ctx, const std::string &name, type_descriptor element_type, const vertex_buffer &vbo, size_t offset_in_bytes, size_t nr_elements, unsigned stride_in_bytes) |
template<typename C , typename T > | |
bool | set_composed_attribute_array (const context &ctx, const std::string &name, const C *array_ptr, size_t nr_elements, const T &elem) |
in case that several attributes are stored interleaved, call this function for the first and ref_composed_attribute_array() for all others | |
template<typename C , typename T > | |
bool | ref_composed_attribute_array (const context &ctx, const std::string &name, const std::string &name_ref, const C *array_ptr, size_t nr_elements, const T &elem) |
in case that several attributes are stored interleaved, call set_composed_attribute_array() for the first and this function for all others | |
bool | remove_attribute_array (const context &ctx, const std::string &name) |
Protected Attributes | |
bool | has_extents |
store whether extent array has been specified | |
bool | has_translations |
whether array with per slab translations has been specified | |
bool | has_rotations |
whether array with per slab rotations has been specified | |
bool | has_texture_indices |
whether array with per slab texture index has been specified | |
bool | position_is_center |
whether position is slab center, if not it is lower left bottom corner | |
![]() | |
bool | has_group_indices |
bool | has_group_colors |
bool | has_group_translations |
bool | has_group_rotations |
![]() | |
bool | has_colors |
track whether color attribute is defined | |
bool | has_positions |
track whether position attribute is defined | |
renderer that supports point splatting
Definition at line 55 of file slab_renderer.h.
cgv::render::slab_renderer::slab_renderer | ( | ) |
initializes position_is_center to true
Definition at line 36 of file slab_renderer.cxx.
References has_extents, has_rotations, has_texture_indices, has_translations, and position_is_center.
|
protectedvirtual |
build slab program
Reimplemented from cgv::render::renderer.
Definition at line 85 of file slab_renderer.cxx.
References cgv::render::shader_program::build_program().
|
protectedvirtual |
overload to allow instantiation of box_renderer
Implements cgv::render::renderer.
Definition at line 15 of file slab_renderer.cxx.
|
virtual |
disable renderer
Reimplemented from cgv::render::group_renderer.
Definition at line 118 of file slab_renderer.cxx.
References cgv::render::renderer::attributes_persist(), cgv::render::group_renderer::disable(), has_extents, has_rotations, has_translations, and position_is_center.
|
virtual |
call this after last render/draw call to ensure that no other users of renderer change attribute arrays of given manager
Reimplemented from cgv::render::group_renderer.
Definition at line 58 of file slab_renderer.cxx.
References cgv::render::group_renderer::disable_attribute_array_manager(), has_extents, has_rotations, has_texture_indices, and has_translations.
|
virtual |
Draw a range of vertices or indexed elements.
Call this function only successful enabeling via validate_and_enable() or enable(). Capsulates glDrawArrays and glDrawElements calls. Overloaded implementations of specific renderers choose the to be used gl primitive type and whether to use an instanced draw call.
count | number of to be drawn vertices/elements |
start | index of first to be drawn vertex/element |
use_strips | whether to generate primitives in strips (only for line or triangle primitives) |
use_adjacency | whether to specify adjacency information (only for line or triangle primitives) |
strip_restart_index | extraorindary index used to mark end of strips (only for strip based drawing) Strip based drawing can be combined with the use of adjacency information. Default implementation uses triangle primitives. |
Reimplemented from cgv::render::renderer.
Definition at line 133 of file slab_renderer.cxx.
References cgv::render::renderer::draw_impl().
|
virtual |
overload to activate group style
Reimplemented from cgv::render::group_renderer.
Definition at line 90 of file slab_renderer.cxx.
References cgv::render::group_renderer::enable(), cgv::render::slab_render_style::falloff_mix, cgv::render::slab_render_style::falloff_strength, has_rotations, has_texture_indices, has_translations, cgv::render::slab_render_style::opacity, position_is_center, cgv::render::renderer::ref_prog(), cgv::render::slab_render_style::scale, cgv::render::shader_program::set_uniform(), cgv::render::slab_render_style::step_size, cgv::render::slab_render_style::tex_idx_offset, cgv::render::slab_render_style::tex_idx_stride, cgv::render::slab_render_style::tex_unit, cgv::render::slab_render_style::tf_tex_unit, cgv::render::slab_render_style::thickness_scale, and cgv::render::slab_render_style::use_transfer_function.
|
virtual |
call this before setting attribute arrays to manage attribute array in given manager
Reimplemented from cgv::render::group_renderer.
Definition at line 45 of file slab_renderer.cxx.
References cgv::render::group_renderer::enable_attribute_array_manager(), cgv::render::renderer::has_attribute(), has_extents, has_rotations, has_texture_indices, and has_translations.
|
inline |
specify box array directly. This sets position_is_center to false as well as position and extent array
Definition at line 103 of file slab_renderer.h.
|
inline |
specify box array directly. This sets position_is_center to false as well as position and extent array
Definition at line 94 of file slab_renderer.h.
|
inline |
specify a single extent for all slabs
Definition at line 85 of file slab_renderer.h.
|
inline |
extent array specifies slab extends in case of position_is_center=true, otherwise the maximum point of each slab
Definition at line 88 of file slab_renderer.h.
|
inline |
extent array specifies slab extends in case of position_is_center=true, otherwise the maximum point of each slab
Definition at line 91 of file slab_renderer.h.
void cgv::render::slab_renderer::set_position_is_center | ( | bool | _position_is_center | ) |
set the flag, whether the position is interpreted as the slab center, true by default
set the flag, whether the position is interpreted as the slab center
Definition at line 68 of file slab_renderer.cxx.
References position_is_center.
|
inline |
template method to set the rotation from a vector of quaternions of type T, which should have 4 components
Definition at line 118 of file slab_renderer.h.
|
inline |
template method to set the rotation from a vector of quaternions of type T, which should have 4 components
Definition at line 121 of file slab_renderer.h.
|
inline |
extent array specifies slab extends in case of position_is_center=true, otherwise the maximum point of each slab
Definition at line 124 of file slab_renderer.h.
|
inline |
extent array specifies slab extends in case of position_is_center=true, otherwise the maximum point of each slab
Definition at line 127 of file slab_renderer.h.
|
inline |
template method to set the translations from a vector of vectors of type T, which should have 3 components
Definition at line 112 of file slab_renderer.h.
|
inline |
template method to set the translations from a vector of vectors of type T, which should have 3 components
Definition at line 115 of file slab_renderer.h.
|
virtual |
check additionally the group attributes
Reimplemented from cgv::render::group_renderer.
Definition at line 73 of file slab_renderer.cxx.
References cgv::render::context::error(), has_extents, and cgv::render::group_renderer::validate_attributes().
|
protected |
store whether extent array has been specified
Definition at line 59 of file slab_renderer.h.
Referenced by disable(), disable_attribute_array_manager(), enable_attribute_array_manager(), slab_renderer(), and validate_attributes().
|
protected |
whether array with per slab rotations has been specified
Definition at line 63 of file slab_renderer.h.
Referenced by disable(), disable_attribute_array_manager(), enable(), enable_attribute_array_manager(), and slab_renderer().
|
protected |
whether array with per slab texture index has been specified
Definition at line 65 of file slab_renderer.h.
Referenced by disable_attribute_array_manager(), enable(), enable_attribute_array_manager(), and slab_renderer().
|
protected |
whether array with per slab translations has been specified
Definition at line 61 of file slab_renderer.h.
Referenced by disable(), disable_attribute_array_manager(), enable(), enable_attribute_array_manager(), and slab_renderer().
|
protected |
whether position is slab center, if not it is lower left bottom corner
Definition at line 67 of file slab_renderer.h.
Referenced by disable(), enable(), set_position_is_center(), and slab_renderer().