cgv
Loading...
Searching...
No Matches
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
10namespace cgv { // @<
11 namespace render { // @<
12
14 struct CGV_API group_render_style : public render_style
15 {
17 bool use_group_color = false;
19 bool use_group_transformation = false;
20 };
21
23 class CGV_API group_renderer : public renderer
24 {
25 protected:
26 bool has_group_indices = false;
27 bool has_group_colors = false;
28 bool has_group_translations = false;
29 bool has_group_rotations = false;
30 public:
32 void enable_attribute_array_manager(const context& ctx, attribute_array_manager& aam);
34 void disable_attribute_array_manager(const context& ctx, attribute_array_manager& aam);
36 bool validate_attributes(const context& ctx) const;
38 bool enable(context& ctx);
40 bool disable(context& ctx);
42 void set_group_index_array(const context& ctx, const std::vector<unsigned>& group_indices);
44 void set_group_index_array(const context& ctx, const unsigned* group_indices, size_t nr_elements);
46 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);
48 template <typename T>
49 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); }
51 void remove_group_index_array(const context& ctx);
53 template <typename T>
54 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); }
56 template <typename T>
57 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); }
59 template <typename T>
60 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); }
62 template <typename T>
63 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); }
65 template <typename T>
66 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); }
68 template <typename T>
69 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); }
70 };
71
73 {
74 bool self_reflect(cgv::reflect::reflection_handler& rh);
75 };
77
78 }
79}
80
81
82//namespace cgv {
83// namespace reflect {
84// namespace render {
85// }
86// }
87//}
88
89
90#include <cgv/config/lib_end.h>
the self reflection handler is passed to the virtual self_reflect() method of cgv::base::base.
attribute array manager used to upload arrays to gpu
base class for all drawables, which is independent of the used rendering API.
Definition context.h:627
abstract renderer class that provides functionality for grouping primitives
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...
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...
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...
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
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,...
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
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...
abstract base class for all renderers that handles a shader program and position / color attribute
Definition renderer.h:23
a vertex buffer is an unstructured memory block on the GPU.
the cgv namespace
Definition print.h:11
this reflection traits implementation is used for external self_reflect implementations of instances ...
render style used for group information
base class for all render styles
Definition renderer.h:16
compact type description of data that can be sent to the context; convertible to int
Definition context.h:56