cgv
cgv::render::point_renderer Class Reference

renderer that supports point splatting More...

#include <point_renderer.h>

Inheritance diagram for cgv::render::point_renderer:
cgv::render::group_renderer cgv::render::renderer

Public Types

typedef cgv::media::color< float, cgv::media::RGB > rgb
 declare rgb color type
 
typedef cgv::media::color< float, cgv::media::RGB, cgv::media::OPACITY > rgba
 declare rgba color type
 
typedef cgv::media::color< cgv::type::uint8_type, cgv::media::RGB > rgb8
 declare rgb color type
 
typedef cgv::media::color< cgv::type::uint8_type, cgv::media::RGB, cgv::media::OPACITY > rgba8
 declare rgba color type
 
typedef cgv::math::fvec< float, 2 > vec2
 declare type of 2d vectors
 
typedef cgv::math::fvec< float, 3 > vec3
 declare type of 3d vectors
 
typedef cgv::math::fvec< float, 4 > vec4
 declare type of homogeneous vectors
 
typedef cgv::math::vec< float > vecn
 declare type of vector with varying dimension
 
typedef cgv::math::fmat< float, 2, 2 > mat2
 declare type of 2x2 matrices
 
typedef cgv::math::fmat< float, 3, 3 > mat3
 declare type of 3x3 matrices
 
typedef cgv::math::fmat< float, 4, 4 > mat4
 declare type of 4x4 matrices
 
typedef cgv::math::fmat< float, 3, 4 > mat34
 declare type of 3x4 matrices which are often used to store a pose
 
typedef cgv::math::mat< float > matn
 declare type of matrices of varying dimensions
 
typedef cgv::math::fvec< double, 2 > dvec2
 declare type of 2d vectors
 
typedef cgv::math::fvec< double, 3 > dvec3
 declare type of 3d vectors
 
typedef cgv::math::fvec< double, 4 > dvec4
 declare type of homogeneous vectors
 
typedef cgv::math::vec< double > dvecn
 declare type of vector with varying dimension
 
typedef cgv::math::fmat< double, 2, 2 > dmat2
 declare type of 2x2 matrices
 
typedef cgv::math::fmat< double, 3, 3 > dmat3
 declare type of 3x3 matrices
 
typedef cgv::math::fmat< double, 4, 4 > dmat4
 declare type of 4x4 matrices
 
typedef cgv::math::fmat< double, 3, 4 > dmat34
 declare type of 3x4 matrices which are often used to store a pose
 
typedef cgv::math::mat< double > dmatn
 declare type of matrices of varying dimensions
 
typedef cgv::media::axis_aligned_box< float, 2 > box2
 declare type of 2d boxes
 
typedef cgv::media::axis_aligned_box< float, 3 > box3
 declare type of 3d boxes
 
typedef cgv::media::axis_aligned_box< float, 4 > box4
 declare type of 4d boxes
 
typedef cgv::media::axis_aligned_box< double, 2 > dbox2
 declare type of 2d boxes
 
typedef cgv::media::axis_aligned_box< double, 3 > dbox3
 declare type of 3d boxes
 
typedef cgv::media::axis_aligned_box< double, 4 > dbox4
 declare type of 4d boxes
 
typedef cgv::math::quaternion< float > quat
 declare type of quaternion
 
typedef cgv::math::quaternion< double > dquat
 declare type of double quaternion
 
typedef cgv::math::fvec< int32_t, 2 > ivec2
 declare type of 2d integer vectors
 
typedef cgv::math::fvec< int32_t, 3 > ivec3
 declare type of 3d integer vectors
 
typedef cgv::math::fvec< int32_t, 4 > ivec4
 declare type of 4d integer vectors
 
typedef cgv::math::fvec< uint32_t, 2 > uvec2
 declare type of 2d unsigned integer vectors
 
typedef cgv::math::fvec< uint32_t, 3 > uvec3
 declare type of 3d unsigned integer vectors
 
typedef cgv::math::fvec< uint32_t, 4 > uvec4
 declare type of 4d unsigned integer vectors
 

Public Member Functions

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
 
bool init (context &ctx)
 abstract initialize method creates default render style, derived renderers to load the shader program
 
template<typename T = float>
void set_depth_offset_array (const context &ctx, const std::vector< T > &depth_offsets)
 set per point depth offsets
 
bool validate_attributes (const context &ctx) const
 check additionally the group attributes
 
bool enable (context &ctx)
 overload to activate group style
 
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)
 convenience function to render with default settings
 
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 More...
 
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
 
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_programref_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 the disable() function, which is also called by the render() function More...
 
void manage_singleton (context &ctx, const std::string &renderer_name, int &ref_count, int ref_count_change)
 used by derived classes to manage singeltons
 
 DEPRECATED ("deprecated, use enable_attribute_array_manager() paired with disable_attribute_manager instead().") virtual void set_attribute_array_manager(const context &ctx
 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
 
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
 
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
 
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. If an attribute array manager is enabled and keep_on_cpu is false (default), create GPU index buffer and transfer indices into it. More...
 
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. If an attribute array manager is enabled and keep_on_cpu is false (default), create GPU index buffer and transfer indices into it. More...
 
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. If an attribute array manager is enabled its index buffer is removed through this call. More...
 
bool has_indices () const
 return whether indices have been defined
 
void remove_indices (const context &ctx)
 remove previously set indices
 
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. More...
 
virtual void clear (const context &ctx)
 the clear function destructs the shader program
 

Protected Member Functions

render_stylecreate_render_style () const
 overload to allow instantiation of point_renderer
 
bool has_aam () const
 check for attribute array manager
 
bool has_attribute (const context &ctx, const std::string &attr_name)
 check for attribute
 
const render_styleget_style_ptr () const
 access to render style
 
bool attributes_persist () const
 return whether attributes persist after a call to disable
 
template<typename T >
const T & get_style () const
 access to style
 
template<typename C , typename T >
bool set_composed_attribute_array (const context &ctx, int loc, 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, int loc, int loc_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
 
void draw_impl (context &ctx, PrimitiveType pt, size_t start, size_t count, bool use_strips, bool use_adjacency, uint32_t strip_restart_index)
 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, bool use_adjacency, uint32_t strip_restart_index)
 default implementation of instanced draw method with support for indexed rendering and different primitive types
 

Protected Attributes

bool has_colors
 track whether color attribute is defined
 
bool has_positions
 track whether position attribute is defined
 

Detailed Description

renderer that supports point splatting

Member Function Documentation

◆ render()

bool cgv::render::renderer::render ( context ctx,
size_t  start,
size_t  count,
bool  use_strips = false,
bool  use_adjacency = false,
uint32_t  strip_restart_index = -1 
)
virtualinherited

Convenience function that draws vertex or indexed element with this renderer.

This function effectively calls validate_and_enable(), draw() and disable(), passes its parameters to draw and returns the result of validate_and_enable(). draw() and disable() are only executed if validate_and_enable() succeeds. For performance reasons this function should not be used for several successive draw calls due to the unnecessary enabling and disabling between render calls. Typically, this function does not need to be overloaded by specific renderers.

See also
draw()
validate_and_enable()

◆ set_group_index_array()

void cgv::render::group_renderer::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 
)
inherited

method to set the group index attribute from a vertex buffer object, the element type must be given as explicit template parameter

template method to set the group index attribute from a vertex buffer object, the element type must be given as explicit template parameter

◆ set_indices() [1/3]

template<typename T >
bool cgv::render::renderer::set_indices ( const context ctx,
const std::vector< T > &  indices,
bool  keep_on_cpu = false 
)
inlineinherited

Set the indices for indexed rendering from a vector. If an attribute array manager is enabled and keep_on_cpu is false (default), create GPU index buffer and transfer indices into it.

Template Parameters
Tindex type must be uint8_t, uint16_t, or uint32_t
Parameters
ctxopengl context in which indexed rendering takes place
indicesvector of indices
keep_on_cpuflag whether indices should be kept in CPU memory
Returns
this can only fail if indices cannot be copied to GPU buffer

◆ set_indices() [2/3]

template<typename T >
bool cgv::render::renderer::set_indices ( const context ctx,
const T *  indices,
size_t  nr_indices,
bool  keep_on_cpu = false 
)
inlineinherited

Set the indices for indexed rendering from an array given as a pointer. If an attribute array manager is enabled and keep_on_cpu is false (default), create GPU index buffer and transfer indices into it.

Template Parameters
Tindex type must be uint8_t, uint16_t, or uint32_t
Parameters
ctxopengl context in which indexed rendering takes place
indicespointer to array containing the indices
nr_indicesnumber of indices in the array
keep_on_cpuflag whether indices should be kept in CPU memory
Returns
this can only fail if indices cannot be copied to GPU buffer

◆ set_indices() [3/3]

template<typename T >
bool cgv::render::renderer::set_indices ( const context ctx,
const vertex_buffer vbo,
size_t  count 
)
inlineinherited

Set the indices for indexed rendering from a GPU buffer. If an attribute array manager is enabled its index buffer is removed through this call.

Template Parameters
Tindex type must be uint8_t, uint16_t, or uint32_t
Parameters
ctxopengl context in which indexed rendering takes place
vboGPU buffer
countnumber of indices in the GPU buffer
Returns
in current implementation this succeeds always

◆ set_prog()

void cgv::render::renderer::set_prog ( shader_program one_shot_prog)
inherited

set external shader program up to next call to the disable() function, which is also called by the render() function

set external shader program for successive draw call only


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