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"
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
101 float y_view_angle = 45.0f;
108 void set_y_view_angle(
float y_view_angle);
114 bool init(
context& ctx)
override;
116 void set_position_is_center(
bool _position_is_center);
118 template <
typename T>
121 template <
typename T>
124 template <
typename T>
127 void remove_extent_array(
const context& ctx);
129 template <
typename T>
138 template <
typename T>
147 template <
typename T>
164 has_texcoords =
true;
174 has_texcoords =
true;
178 template <
typename T>
181 template <
typename T>
184 template <
typename T>
187 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);
189 template <
typename T>
190 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); }
192 void remove_secondary_color_array(
const context& ctx);
195 template <
typename T>
198 template <
typename T>
201 template <
typename T>
204 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);
206 template <
typename T>
207 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); }
209 void remove_border_color_array(
const context& ctx);
211 template <
typename T>
214 template <
typename T>
217 template <
typename T>
218 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); }
222 template <
typename T>
223 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); }
225 void remove_border_info_array(
const context& ctx);
228 template <
typename T>
231 template <
typename T =
float>
234 void remove_depth_offset_array(
const context& ctx);
236 template <
typename T>
239 template <
typename T>
242 template <
typename T>
245 void remove_translation_array(
const context& ctx);
247 template <
typename T>
250 template <
typename T>
253 template <
typename T>
256 void remove_rotation_array(
const context& ctx);
258 bool validate_attributes(
const context& ctx)
const override;
260 bool enable(
context& ctx)
override;
262 bool disable(
context& ctx)
override;
264 void draw(
context& ctx,
size_t start,
size_t count,
265 bool use_strips =
false,
bool use_adjacency =
false, uint32_t strip_restart_index = -1)
override;
275#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...
render_style * create_render_style() const override
create and return the default render style
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_position_is_center(bool _position_is_center)
set the flag of the render style, whether the position is interpreted as the box center
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
std::string get_default_prog_name() const override
return the default shader program name
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...
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 f...
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_comp...
shader_program & ref_prog()
derived renderer classes have access to shader program
bool has_positions
track whether position attribute is defined
base classes for renderers that support surface rendering
a vertex buffer is an unstructured memory block on the GPU.
namespace for api independent GPU programming
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 header is dependency free
cgv::media::color< float, cgv::media::RGB, cgv::media::OPACITY > rgba
declare rgba color type with 32 bit components
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