3#include "surface_renderer.h"
4#include <cgv/reflect/reflect_enum.h>
5#include <cgv/render/textured_rectangle.h>
7#include "gl/lib_begin.h"
11 class CGV_API rectangle_renderer;
25 RTM_MULTIPLY_SECONDARY_COLOR,
26 RTM_MULTIPLY_BORDER_COLOR,
27 RTM_MIX_COLOR_AND_SECONDARY_COLOR,
28 RTM_MIX_COLOR_AND_BORDER_COLOR,
29 RTM_MIX_SECONDARY_COLOR_AND_COLOR,
30 RTM_MIX_BORDER_COLOR_AND_COLOR,
31 RTM_RED_MIX_COLOR_AND_SECONDARY_COLOR,
32 RTM_RED_MIX_COLOR_AND_BORDER_COLOR,
33 RTM_RED_MIX_SECONDARY_COLOR_AND_COLOR,
34 RTM_RED_MIX_BORDER_COLOR_AND_COLOR
112 void set_y_view_angle(
float y_view_angle);
120 void set_position_is_center(
bool _position_is_center);
122 template <
typename T>
125 template <
typename T>
128 template <
typename T>
131 void remove_extent_array(
const context& ctx);
133 template <
typename T>
135 has_positions =
true;
137 set_position_is_center(
false);
138 ref_prog().set_attribute(ctx,
"position", box.
get_min_pnt());
139 ref_prog().set_attribute(ctx,
"extent", box.
get_max_pnt());
142 template <
typename T>
144 set_composed_attribute_array(ctx,
"position", &boxes.front(), boxes.size(), boxes[0].get_min_pnt());
145 ref_composed_attribute_array(ctx,
"extent",
"position", &boxes.front(), boxes.size(), boxes[0].get_max_pnt());
146 has_positions =
true;
148 set_position_is_center(
false);
151 template <
typename T>
153 set_composed_attribute_array(ctx,
"position", boxes, count, boxes[0].get_min_pnt());
154 ref_composed_attribute_array(ctx,
"extent",
"position", boxes, count, boxes[0].get_max_pnt());
155 has_positions =
true;
157 set_position_is_center(
false);
163 set_composed_attribute_array(ctx,
"position", &tc_rects.front(), tc_rects.size(), tc_rects[0].rectangle.get_min_pnt());
164 ref_composed_attribute_array(ctx,
"extent",
"position", &tc_rects.front(), tc_rects.size(), tc_rects[0].rectangle.get_max_pnt());
165 ref_composed_attribute_array(ctx,
"texcoord",
"position", &tc_rects.front(), tc_rects.size(), tc_rects[0].texcoords);
166 has_positions =
true;
168 has_texcoords =
true;
169 set_position_is_center(
false);
173 set_composed_attribute_array(ctx,
"position", tc_rects, count, tc_rects[0].rectangle.get_min_pnt());
174 ref_composed_attribute_array(ctx,
"extent",
"position", tc_rects, count, tc_rects[0].rectangle.get_max_pnt());
175 ref_composed_attribute_array(ctx,
"texcoord",
"position", tc_rects, count, tc_rects[0].texcoords);
176 has_positions =
true;
178 has_texcoords =
true;
179 set_position_is_center(
false);
182 template <
typename T>
183 void set_secondary_color(
const context& ctx,
const T& color) { has_secondary_colors =
true; ref_prog().set_attribute(ctx,
"secondary_color", color); }
185 template <
typename T>
188 template <
typename T>
189 void set_secondary_color_array(
const context& ctx,
const T* colors,
size_t nr_elements,
unsigned stride_in_bytes = 0) { has_secondary_colors =
true; set_attribute_array(ctx,
"secondary_color", colors, nr_elements, stride_in_bytes); }
191 void set_secondary_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);
193 template <
typename T>
194 void set_secondary_color_array(
const context& ctx,
const vertex_buffer& vbo,
size_t offset_in_bytes,
size_t nr_elements,
unsigned stride_in_bytes = 0) {
set_secondary_color_array(ctx,
type_descriptor(
element_descriptor_traits<T>::get_type_descriptor(T()),
true), vbo, offset_in_bytes, nr_elements, stride_in_bytes); }
196 void remove_secondary_color_array(
const context& ctx);
199 template <
typename T>
200 void set_border_color(
const context& ctx,
const T& color) { has_border_colors =
true; ref_prog().set_attribute(ctx, get_prog_attribute_location(ctx,
"border_color"), color); }
202 template <
typename T>
203 void set_border_color_array(
const context& ctx,
const std::vector<T>& colors) { has_border_colors =
true; set_attribute_array(ctx,
"border_color", colors); }
205 template <
typename T>
206 void set_border_color_array(
const context& ctx,
const T* colors,
size_t nr_elements,
unsigned stride_in_bytes = 0) { has_border_colors =
true; set_attribute_array(ctx,
"border_color", colors, nr_elements, stride_in_bytes); }
208 void set_border_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);
210 template <
typename T>
211 void set_border_color_array(
const context& ctx,
const vertex_buffer& vbo,
size_t offset_in_bytes,
size_t nr_elements,
unsigned stride_in_bytes = 0) {
set_border_color_array(ctx,
type_descriptor(
element_descriptor_traits<T>::get_type_descriptor(T()),
true), vbo, offset_in_bytes, nr_elements, stride_in_bytes); }
213 void remove_border_color_array(
const context& ctx);
215 template <
typename T>
218 template <
typename T>
219 void set_border_info_array(
const context& ctx,
const std::vector<T>& border_infos) { has_border_infos =
true; set_attribute_array(ctx,
"border_info", border_infos); }
221 template <
typename T>
222 void set_border_info_array(
const context& ctx,
const T* border_infos,
size_t nr_elements,
unsigned stride_in_bytes = 0) { has_border_infos =
true; set_attribute_array(ctx,
"border_info", border_infos, nr_elements, stride_in_bytes); }
226 template <
typename T>
227 void set_border_info_array(
const context& ctx,
const vertex_buffer& vbo,
size_t offset_in_bytes,
size_t nr_elements,
unsigned stride_in_bytes = 0) {
set_border_info_array(ctx,
type_descriptor(
element_descriptor_traits<T>::get_type_descriptor(T()),
true), vbo, offset_in_bytes, nr_elements, stride_in_bytes); }
229 void remove_border_info_array(
const context& ctx);
232 template <
typename T>
233 void set_depth_offset(
const context& ctx,
const T& depth_offset) { has_depth_offsets =
true; ref_prog().set_attribute(ctx, get_prog_attribute_location(ctx,
"depth_offset"), depth_offset); }
235 template <
typename T =
float>
236 void set_depth_offset_array(
const context& ctx,
const std::vector<T>& depth_offsets) { has_depth_offsets =
true; set_attribute_array(ctx,
"depth_offset", depth_offsets); }
238 void remove_depth_offset_array(
const context& ctx);
240 template <
typename T>
241 void set_translation(
const context& ctx,
const T& translation) { has_translations =
true; ref_prog().set_attribute(ctx, get_prog_attribute_location(ctx,
"translation"), translation); }
243 template <
typename T>
244 void set_translation_array(
const context& ctx,
const std::vector<T>& translations) { has_translations =
true; set_attribute_array(ctx,
"translation", translations); }
246 template <
typename T>
247 void set_translation_array(
const context& ctx,
const T* translations,
size_t nr_elements,
unsigned stride) { has_translations =
true; set_attribute_array(ctx,
"translation", translations, nr_elements, stride); }
249 void remove_translation_array(
const context& ctx);
251 template <
typename T>
252 void set_rotation(
const context& ctx,
const T& rotation) { has_rotations =
true; ref_prog().set_attribute(ctx, get_prog_attribute_location(ctx,
"rotation"), rotation); }
254 template <
typename T>
255 void set_rotation_array(
const context& ctx,
const std::vector<T>& rotations) { has_rotations =
true; set_attribute_array(ctx,
"rotation", rotations); }
257 template <
typename T>
258 void set_rotation_array(
const context& ctx,
const T* rotations,
size_t nr_elements,
unsigned stride = 0) { has_rotations =
true; set_attribute_array(ctx,
"rotation", rotations, nr_elements, stride); }
260 void remove_rotation_array(
const context& ctx);
262 bool validate_attributes(
const context& ctx)
const;
268 void draw(
context& ctx,
size_t start,
size_t count,
269 bool use_strips =
false,
bool use_adjacency =
false, uint32_t strip_restart_index = -1);
279#include <cgv/config/lib_end.h>
A vector with zero based index.
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.
renderer that supports plane rendering
void set_secondary_color(const context &ctx, const T &color)
templated method to set the secondary color attribute from a single color of type T
void set_border_color_array(const context &ctx, const T *colors, size_t nr_elements, unsigned stride_in_bytes=0)
template method to set the border color attribute from a vector of colors of type T
bool has_extents
whether extent array has been specified
void set_depth_offset_array(const context &ctx, const std::vector< T > &depth_offsets)
set per rectangle depth offsets
void set_border_color_array(const context &ctx, const std::vector< T > &colors)
template method to set the border color attribute from a vector of colors of type T
void set_secondary_color_array(const context &ctx, const T *colors, size_t nr_elements, unsigned stride_in_bytes=0)
template method to set the secondary color attribute from a vector of colors of type 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 compo...
void set_extent_array(const context &ctx, const cgv::math::fvec< T, 2U > *extents, size_t nr_elements, unsigned stride_in_bytes=0)
extent array specifies plane side lengths from origin to edge
void set_textured_rectangle_array(const context &ctx, const std::vector< textured_rectangle > &tc_rects)
specify rectangle array directly. This sets position_is_center to false as well as position and exten...
bool has_border_colors
whether border color or color array was set
void set_rectangle(const context &ctx, const cgv::media::axis_aligned_box< T, 2 > &box)
specify a single rectangle without array. This sets position_is_center to false as well as position a...
void set_border_info_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 border_info attribute from a vertex buffer object, the element type must b...
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 compo...
bool has_secondary_colors
whether secondary color or color array was set
void set_textured_rectangle_array(const context &ctx, const textured_rectangle *tc_rects, size_t count)
specify ractangle array directly. This sets position_is_center to false as well as position and exten...
void set_rectangle_array(const context &ctx, const cgv::media::axis_aligned_box< T, 2 > *boxes, size_t count)
specify ractangle array directly. This sets position_is_center to false as well as position and exten...
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 compo...
bool has_depth_offsets
whether depth offset array has been specified
void set_border_info_array(const context &ctx, const std::vector< T > &border_infos)
templated method to set the border_info attribute array from a vector of border_infos of type T,...
void set_rotation(const context &ctx, const T &rotation)
set single rotation for all rectangles from a quaternion of type T, which has 4 components
void set_border_info_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 border_info attribute from a vertex buffer object, the element type must be given a...
void set_border_info(const context &ctx, const cgv::math::fvec< T, 3 > &border_info)
specify a single border_info for all lines
bool has_border_infos
whether border info or info array was set
bool has_translations
whether translation array has been specified
void set_secondary_color_array(const context &ctx, const std::vector< T > &colors)
template method to set the secondary color attribute from a vector of colors of type T
void set_border_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 border color attribute from a vertex buffer object, the element type must ...
void set_translation(const context &ctx, const T &translation)
template method to set translation for all rectangles from a vector type T, which should have 3 compo...
void set_rotation_array(const context &ctx, const T *rotations, size_t nr_elements, unsigned stride=0)
template method to set the rotation from a vector of quaternions of type T, which should have 4 compo...
void set_depth_offset(const context &ctx, const T &depth_offset)
specify a single depth_offset for all lines
void set_secondary_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 secondary color attribute from a vertex buffer object, the element type mu...
void set_extent_array(const context &ctx, const std::vector< cgv::math::fvec< T, 2U > > &extents)
extent array specifies plane side lengths from origin to edge
bool has_rotations
whether rotation array has been specified
void set_border_color(const context &ctx, const T &color)
templated method to set the border color attribute from a single color of type T
void set_border_info_array(const context &ctx, const T *border_infos, size_t nr_elements, unsigned stride_in_bytes=0)
templated method to set the border_info attribute from an array of border_infos of type T,...
void set_extent(const context &ctx, const cgv::math::fvec< T, 2U > &extent)
specify a single extent for all boxes
void set_rectangle_array(const context &ctx, const std::vector< cgv::media::axis_aligned_box< T, 2 > > &boxes)
specify rectangle array directly. This sets position_is_center to false as well as position and exten...
a shader program combines several shader code fragments to a complete definition of the shading pipel...
base classes for renderers that support surface rendering
a vertex buffer is an unstructured memory block on the GPU.
std::map< std::string, std::string > shader_define_map
typedef for shader define map data structure
rectangle_renderer & ref_rectangle_renderer(context &ctx, int ref_count_change)
reference to a singleton plane renderer that can be shared among drawables
RectangleTextureMode
different modes to use texture during rectangle rendering
RectangleBoderMode
different modes to compute relative border with for rectangle rendering
this type specific reflection traits class is used by the reflect_enum function to reflect enum types
this reflection traits implementation is used for external self_reflect implementations of instances ...
configuration of rectangle renderer
rgba default_secondary_color
default value of secondary color which is ignored if set_secondary_color_array() is used to set per r...
bool blend_rectangles
if true the renderer enables blending in the enable method and recovers previous blending mode on dis...
RectangleBoderMode border_mode
different modes of computing the width of the border (default: RBM_MIN)
float pixel_blend
number of pixels around the rectangle splat used for antialiasing (default: 0.0f)
RectangleTextureMode texture_mode
mode of using texture during rastrization (default: RTM_REPLACE)
bool position_is_center
flag whether position attribute is the rectangle center; otherwise position is lower left corner (def...
float border_width_in_pixel
border width measured in pixels (default: 0)
rgba default_border_color
default value for the border color attribute which is ignored when set_border_color_array() is used t...
float default_depth_offset
default depth offset added to depth value of fragment. (default: 0.0f)
float percentual_border_width
border width measured relative to rectangle extent computed according to current border_mode (default...
base class for all render styles
This type provides a simple helper class to store rectangles with texture coordinates.
compact type description of data that can be sent to the context; convertible to int