cgv
Loading...
Searching...
No Matches
arrow_renderer.h
1#pragma once
2
3#include "surface_renderer.h"
4
5#include "gl/lib_begin.h"
6
7namespace cgv {
8 namespace render {
9 class CGV_API arrow_renderer;
10
12
15 extern CGV_API arrow_renderer& ref_arrow_renderer(context& ctx, int ref_count_change = 0);
16
21 {
22 AHLM_RELATIVE_TO_RADIUS = 1,
23 AHLM_RELATIVE_TO_LENGTH = 2,
24 AHLM_MINIMUM_OF_RADIUS_AND_LENGTH = 3
25 };
26
29 {
30 /*@name arrow rendering attributes*/
32
33 float radius_lower_bound = 0.00001f;
35 float radius_relative_to_length = 0.1f;
37 float head_radius_scale = 2.0f;
39 ArrowHeadLengthMode head_length_mode = AHLM_MINIMUM_OF_RADIUS_AND_LENGTH;
41 float head_length_relative_to_radius = 2.0f;
43 float head_length_relative_to_length = 0.3f;
45 float length_scale = 1.0f;
47 float color_scale = 1.0f;
49 bool normalize_length = false;
51 float relative_location_of_position = 0.0f;
53 float length_eps = 0.000001f;
55 };
56
58 class CGV_API arrow_renderer : public surface_renderer
59 {
60 protected:
61 bool has_directions = false;
62 bool position_is_center = false;
63 bool direction_is_end_point = false;
65 std::string get_default_prog_name() const override { return "arrow.glpr"; }
67 render_style* create_render_style() const override { return new arrow_render_style(); }
69 bool build_shader_program(context& ctx, shader_program& prog, const shader_compile_options& options) const override;
70 public:
72 void enable_attribute_array_manager(const context& ctx, attribute_array_manager& aam) override;
74 void disable_attribute_array_manager(const context& ctx, attribute_array_manager& aam) override;
76 template <typename T>
77 void set_direction_array(const context& ctx, const std::vector<T>& directions) { has_directions = true; direction_is_end_point = false; set_attribute_array(ctx, "direction", directions); }
79 template <typename T>
80 void set_direction_array(const context& ctx, const T* directions, size_t nr_elements, unsigned stride_in_bytes = 0) { has_directions = true; direction_is_end_point = false; set_attribute_array(ctx, "direction", directions, nr_elements, stride_in_bytes); }
82 void remove_direction_array(const context& ctx);
84 template <typename T>
85 void set_end_point_array(const context& ctx, const std::vector<T>& end_points) { has_directions = true; direction_is_end_point = true; set_attribute_array(ctx, "direction", end_points); }
87 template <typename T>
88 void set_end_point_array(const context& ctx, const T* end_points, size_t nr_elements, unsigned stride_in_bytes = 0) { has_directions = true; direction_is_end_point = true; set_attribute_array(ctx, "direction", end_points, nr_elements, stride_in_bytes); }
90 void remove_end_point_array(const context& ctx);
92 bool validate_attributes(const context& ctx) const override;
94 bool enable(context& ctx) override;
96 bool disable(context& ctx) override;
98 void draw(context& ctx, size_t start, size_t count,
99 bool use_strips = false, bool use_adjacency = false, uint32_t strip_restart_index = -1) override;
100 };
102 {
103 bool self_reflect(cgv::reflect::reflection_handler& rh);
104 };
106 }
107}
108
109#include <cgv/config/lib_end.h>
the self reflection handler is passed to the virtual self_reflect() method of cgv::base::base.
renderer that supports point splatting
render_style * create_render_style() const override
create and return the default render style
void set_direction_array(const context &ctx, const T *directions, size_t nr_elements, unsigned stride_in_bytes=0)
templated method to set the direction attribute from an array of directions of type T,...
void set_end_point_array(const context &ctx, const T *end_points, size_t nr_elements, unsigned stride_in_bytes=0)
templated method to set the end_point attribute from an array of end_points of type T,...
void set_direction_array(const context &ctx, const std::vector< T > &directions)
templated method to set the direction attribute from a vector of directions of type T,...
void set_end_point_array(const context &ctx, const std::vector< T > &end_points)
templated method to set the end_point attribute from a vector of end_points of type T,...
std::string get_default_prog_name() const override
return the default shader program name
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
Stores preprocessor options used for conditionally compiling shader programs.
Definition shader_code.h:73
a shader program combines several shader code fragments to a complete definition of the shading pipel...
base classes for renderers that support surface rendering
arrow_renderer & ref_arrow_renderer(context &ctx, int ref_count_change)
reference to a singleton surfel renderer that can be shared among drawables
ArrowHeadLengthMode
different modes to compute the head length of an arrow
the cgv namespace
Definition print.h:11
this reflection traits implementation is used for external self_reflect implementations of instances ...
base class for all render styles
Definition renderer.h:16