3 #include "surface_renderer.h"
5 #include "gl/lib_begin.h"
9 class CGV_API rectangle_renderer;
17 struct CGV_API rectangle_render_style :
public surface_render_style
22 float percentual_border_width;
23 float border_width_in_pixel;
24 float default_depth_offset;
27 bool blend_rectangles;
29 friend class rectangle_renderer;
30 mutable GLboolean is_blend;
31 mutable GLint blend_src, blend_dst;
33 rectangle_render_style();
57 void set_y_view_angle(
float y_view_angle);
65 void set_position_is_center(
bool _position_is_center);
74 void set_extent_array(
const context& ctx,
const cgv::math::fvec<T, 2U>* extents,
size_t nr_elements,
unsigned stride_in_bytes = 0) { has_extents =
true; set_attribute_array(ctx, ref_prog().get_attribute_location(ctx,
"extent"), extents, nr_elements, stride_in_bytes); }
80 set_position_is_center(
false);
81 ref_prog().set_attribute(ctx, ref_prog().get_position_index(), box.
get_min_pnt());
82 ref_prog().set_attribute(ctx, ref_prog().get_attribute_location(ctx,
"extent"), box.
get_max_pnt());
87 set_composed_attribute_array(ctx, ref_prog().get_attribute_location(ctx,
"position"),
88 &boxes.front(), boxes.size(), boxes[0].get_min_pnt());
89 ref_composed_attribute_array(ctx, ref_prog().get_attribute_location(ctx,
"extent"),
90 ref_prog().get_attribute_location(ctx,
"position"), &boxes.front(), boxes.size(), boxes[0].get_max_pnt());
93 set_position_is_center(
false);
98 set_composed_attribute_array(ctx, ref_prog().get_attribute_location(ctx,
"position"),
99 boxes, count, boxes[0].get_min_pnt());
100 ref_composed_attribute_array(ctx, ref_prog().get_attribute_location(ctx,
"extent"),
101 ref_prog().get_attribute_location(ctx,
"position"), boxes, count, boxes[0].get_max_pnt());
102 has_positions =
true;
104 set_position_is_center(
false);
110 set_composed_attribute_array(ctx, ref_prog().get_attribute_location(ctx,
"position"),
111 &tc_rects.front(), tc_rects.size(), tc_rects[0].rectangle.get_min_pnt());
112 ref_composed_attribute_array(ctx, ref_prog().get_attribute_location(ctx,
"extent"),
113 ref_prog().get_attribute_location(ctx,
"position"), &tc_rects.front(), tc_rects.size(), tc_rects[0].rectangle.get_max_pnt());
114 ref_composed_attribute_array(ctx, ref_prog().get_attribute_location(ctx,
"texcoord"),
115 ref_prog().get_attribute_location(ctx,
"position"), &tc_rects.front(), tc_rects.size(), tc_rects[0].texcoords);
116 has_positions =
true;
118 has_texcoords =
true;
119 set_position_is_center(
false);
123 set_composed_attribute_array(ctx, ref_prog().get_attribute_location(ctx,
"position"),
124 tc_rects, count, tc_rects[0].rectangle.get_min_pnt());
125 ref_composed_attribute_array(ctx, ref_prog().get_attribute_location(ctx,
"extent"),
126 ref_prog().get_attribute_location(ctx,
"position"), tc_rects, count, tc_rects[0].rectangle.get_max_pnt());
127 ref_composed_attribute_array(ctx, ref_prog().get_attribute_location(ctx,
"texcoord"),
128 ref_prog().get_attribute_location(ctx,
"position"), tc_rects, count, tc_rects[0].texcoords);
129 has_positions =
true;
131 has_texcoords =
true;
132 set_position_is_center(
false);
135 template <
typename T>
136 void set_depth_offset(
const context& ctx,
const T& depth_offset) { has_depth_offsets =
true; ref_prog().set_attribute(ctx, ref_prog().get_attribute_location(ctx,
"depth_offset"), depth_offset); }
138 template <
typename T =
float>
139 void set_depth_offset_array(
const context& ctx,
const std::vector<T>& depth_offsets) { has_depth_offsets =
true; set_attribute_array(ctx, ref_prog().get_attribute_location(ctx,
"depth_offset"), depth_offsets); }
141 template <
typename T>
142 void set_translation_array(
const context& ctx,
const std::vector<T>& translations) { has_translations =
true; set_attribute_array(ctx, ref_prog().get_attribute_location(ctx,
"translation"), translations); }
144 template <
typename T>
145 void set_translation_array(
const context& ctx,
const T* translations,
size_t nr_elements,
unsigned stride) { has_translations =
true; set_attribute_array(ctx, ref_prog().get_attribute_location(ctx,
"translation"), translations, nr_elements, stride); }
147 template <
typename T>
148 void set_rotation_array(
const context& ctx,
const std::vector<T>& rotations) { has_rotations =
true; set_attribute_array(ctx, ref_prog().get_attribute_location(ctx,
"rotation"), rotations); }
150 template <
typename T>
151 void set_rotation_array(
const context& ctx,
const T* rotations,
size_t nr_elements,
unsigned stride = 0) { has_rotations =
true; set_attribute_array(ctx, ref_prog().get_attribute_location(ctx,
"rotation"), rotations, nr_elements, stride); }
153 bool validate_attributes(
const context& ctx)
const;
159 void draw(
context& ctx,
size_t start,
size_t count,
160 bool use_strips =
false,
bool use_adjacency =
false, uint32_t strip_restart_index = -1);
162 struct CGV_API rectangle_render_style_reflect :
public rectangle_render_style
170 #include <cgv/config/lib_end.h>