cgv
group_renderer.h
1 #pragma once
2 
3 #include "renderer.h"
4 #include <cgv/reflect/reflect_extern.h>
5 #include <cgv/render/shader_program.h>
6 #include <cgv_reflect_types/render/context.h>
7 
8 #include "gl/lib_begin.h"
9 
10 namespace cgv { // @<
11  namespace render { // @<
12 
14  struct CGV_API group_render_style : public render_style
15  {
22  };
23 
25  class CGV_API group_renderer : public renderer
26  {
27  protected:
28  bool has_group_indices;
29  bool has_group_colors;
30  bool has_group_translations;
31  bool has_group_rotations;
32  public:
36  void enable_attribute_array_manager(const context& ctx, attribute_array_manager& aam);
38  void disable_attribute_array_manager(const context& ctx, attribute_array_manager& aam);
40  bool validate_attributes(const context& ctx) const;
42  bool enable(context& ctx);
44  bool disable(context& ctx);
46  void set_group_index_array(const context& ctx, const std::vector<unsigned>& group_indices);
48  void set_group_index_array(const context& ctx, const unsigned* group_indices, size_t nr_elements);
50  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);
52  template <typename T>
53  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) { set_group_index_array(ctx, type_descriptor(element_descriptor_traits<T>::get_type_descriptor(T()), true), vbo, offset_in_bytes, nr_elements, stride_in_bytes); }
55  template <typename T>
56  void set_group_colors(const context& ctx, const std::vector<T>& colors) { has_group_colors = true; ref_prog().set_uniform_array(ctx, "group_colors", colors); }
58  template <typename T>
59  void set_group_colors(const context& ctx, const T* colors, size_t nr_elements) { has_group_colors = true; ref_prog().set_uniform_array(ctx, "group_colors", colors, nr_elements); }
61  template <typename T>
62  void set_group_translations(const context& ctx, const std::vector<T>& group_translations) { has_group_translations = true; ref_prog().set_uniform_array(ctx, "group_translations", group_translations); }
64  template <typename T>
65  void set_group_translations(const context& ctx, const T* group_translations, size_t nr_elements) { has_group_translations = true; ref_prog().set_uniform_array(ctx, "group_translations", group_translations, nr_elements); }
67  template <typename T>
68  void set_group_rotations(const context& ctx, const std::vector<T>& group_rotations) { has_group_rotations = true; ref_prog().set_uniform_array(ctx, "group_rotations", group_rotations); }
70  template <typename T>
71  void set_group_rotations(const context& ctx, const T* group_rotations, size_t nr_elements) { has_group_rotations = true; ref_prog().set_uniform_array(ctx, "group_rotations", group_rotations, nr_elements); }
72  };
73 
74  struct CGV_API group_render_style_reflect : public group_render_style
75  {
76  bool self_reflect(cgv::reflect::reflection_handler& rh);
77  };
78  extern CGV_API cgv::reflect::extern_reflection_traits<group_render_style, group_render_style_reflect> get_reflection_traits(const group_render_style&);
79 
80  }
81 }
82 
83 
84 //namespace cgv {
85 // namespace reflect {
86 // namespace render {
87 // }
88 // }
89 //}
90 
91 
92 #include <cgv/config/lib_end.h>
cgv::render::render_style
base class for all render styles
Definition: renderer.h:16
cgv::render::type_descriptor
compact type description of data that can be sent to the context; convertible to int
Definition: context.h:36
cgv::render::group_renderer::set_group_index_array
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,...
Definition: group_renderer.h:53
cgv::render::vertex_buffer
Definition: vertex_buffer.h:13
cgv::render::renderer
abstract base class for all renderers that handles a shader program and position / color attribute
Definition: renderer.h:177
cgv::render::group_render_style
Definition: group_renderer.h:15
cgv::render::group_renderer::set_group_rotations
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...
Definition: group_renderer.h:71
cgv::render::group_renderer::set_group_translations
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...
Definition: group_renderer.h:65
cgv::render::group_render_style::use_group_transformation
bool use_group_transformation
whether to use group translation and rotation indexed through group index, defaults to false
Definition: group_renderer.h:19
cgv::render::attribute_array_manager
attribute array manager used to upload arrays to gpu
Definition: renderer.h:21
cgv::render::group_renderer::set_group_translations
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...
Definition: group_renderer.h:62
cgv::reflect::reflection_handler
Definition: reflection_handler.h:63
cgv::render::group_renderer::set_group_colors
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
Definition: group_renderer.h:56
cgv::render::group_renderer::set_group_rotations
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...
Definition: group_renderer.h:68
cgv::render::group_render_style::use_group_color
bool use_group_color
whether to use group colors indexed through group index, defaults to false
Definition: group_renderer.h:17
cgv::reflect::extern_reflection_traits
this reflection traits implementation is used for external self_reflect implementations of instances ...
Definition: reflect_extern.h:28
cgv::render::group_renderer::set_group_colors
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
Definition: group_renderer.h:59
cgv
the cgv namespace
Definition: vr_calib.cxx:9
cgv::render::context
Definition: context.h:525
cgv::render::group_renderer
abstract renderer class that provides functionality for grouping primitives
Definition: group_renderer.h:26