cgv
Loading...
Searching...
No Matches
point_renderer.h
1#pragma once
2
3#include "group_renderer.h"
4
5#include "gl/lib_begin.h"
6
7namespace cgv {
8 namespace render {
9 class CGV_API point_renderer;
10
12
15 extern CGV_API point_renderer& ref_point_renderer(context& ctx, int ref_count_change = 0);
16
18 struct CGV_API point_render_style : public group_render_style
19 {
20 /*@name point rendering attributes*/
22
23 float point_size = 1.0f;
25 bool use_group_point_size = false;
27 bool measure_point_size_in_pixel = true;
29 bool screen_aligned = true;
31
32 /*@name global point rendering options*/
34
35 float default_depth_offset = 0.0f;
37 float blend_width_in_pixel = 1.0f;
39 float halo_width_in_pixel = 0.0f;
41 float percentual_halo_width = 0.0f;
43 rgba halo_color = { 1.0f };
45 float halo_color_strength = 0.5f;
47 bool blend_points = true;
48 };
49
51 class CGV_API point_renderer : public group_renderer
52 {
53 protected:
54 bool has_point_sizes = false;
55 bool has_group_point_sizes = false;
56 bool has_indexed_colors = false;
57 bool has_depth_offsets = false;
58 float reference_point_size = 0.01f;
59 float y_view_angle = 45.0f;
61 std::string get_default_prog_name() const override { return "point.glpr"; }
63 render_style* create_render_style() const override { return new point_render_style(); }
64 public:
66 void enable_attribute_array_manager(const context& ctx, attribute_array_manager& aam) override;
68 void disable_attribute_array_manager(const context& ctx, attribute_array_manager& aam) override;
70 void set_reference_point_size(float _reference_point_size);
72 void set_y_view_angle(float y_view_angle);
74 template <typename T = float>
75 void set_point_size_array(const context& ctx, const std::vector<T>& point_sizes) { has_point_sizes = true; set_attribute_array(ctx, "point_size", point_sizes); }
77 void remove_point_size_array(const context& ctx);
79 template <typename T = float>
80 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); }
82 void remove_depth_offset_array(const context& ctx);
84 template <typename T = unsigned, typename C = cgv::media::color<float,cgv::media::RGB,cgv::media::OPACITY> >
85 void set_indexed_color_array(const context& ctx, const std::vector<T>& color_indices, const std::vector<C>& palette) {
86 has_indexed_colors = true;
87 set_attribute_array(ctx, "color_index", color_indices);
88 ref_prog().set_uniform_array(ctx, "palette", palette);
89 }
91 void remove_indexed_color_array(const context& ctx);
93 template <typename T = float>
94 void set_group_point_sizes(const context& ctx, const std::vector<T>& group_point_sizes) { has_group_point_sizes = true; ref_prog().set_uniform_array(ctx, "group_point_sizes", group_point_sizes); }
96 bool validate_attributes(const context& ctx) const override;
98 bool enable(context& ctx) override;
100 bool disable(context& ctx) override;
102 void draw(context& ctx, size_t start, size_t count,
103 bool use_strips = false, bool use_adjacency = false, uint32_t strip_restart_index = -1) override;
104 };
106 {
107 bool self_reflect(cgv::reflect::reflection_handler& rh);
108 };
110 }
111}
112
113#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
renderer that supports point splatting
void set_depth_offset_array(const context &ctx, const std::vector< T > &depth_offsets)
set per point depth offsets
render_style * create_render_style() const override
create and return the default render style
std::string get_default_prog_name() const override
return the default shader program name
point_renderer & ref_point_renderer(context &ctx, int ref_count_change)
reference to a singleton point renderer that can be shared among drawables
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