cgv
Loading...
Searching...
No Matches
line_renderer.h
1#pragma once
2
3#include "group_renderer.h"
4#include <cgv/media/color.h>
5
6#include "gl/lib_begin.h"
7
8namespace cgv { // @<
9 namespace render { // @<
10
12 struct CGV_API line_render_style : public group_render_style
13 {
14 // default values for program attributes
15
24
25 // influence on opengl state
26 bool blend_lines;
27 protected:
28 friend class line_renderer;
29 mutable GLboolean is_blend;
30 mutable GLint blend_src, blend_dst;
31 public:
32 // vertex shader uniforms
33
42
43 // geometry shader uniforms
44
51
52 // fragment shader uniforms
53
58 };
59
61 class CGV_API line_renderer : public group_renderer
62 {
63 protected:
64 bool has_normals;
65 bool has_line_widths;
66 bool has_depth_offsets;
68 render_style* create_render_style() const;
70 bool build_shader_program(context& ctx, shader_program& prog, const shader_define_map& defines);
71 public:
75 bool enable(context& ctx);
77 bool disable(context& ctx);
79 void enable_attribute_array_manager(const context& ctx, attribute_array_manager& aam);
81 void disable_attribute_array_manager(const context& ctx, attribute_array_manager& aam);
83 bool init(context& ctx);
85 template <typename T>
86 void set_normal(const context& ctx, const cgv::math::fvec<T,3>& normal) { has_normals = true; ref_prog().set_attribute(ctx, get_prog_attribute_location(ctx, "normal"), normal); }
88 template <typename T>
89 void set_normal_array(const context& ctx, const std::vector<T>& normals) { has_normals = true; set_attribute_array(ctx, "normal", normals); }
91 template <typename T>
92 void set_normal_array(const context& ctx, const T* normals, size_t nr_elements, unsigned stride_in_bytes = 0) { has_normals = true; set_attribute_array(ctx, "normal", normals, nr_elements, stride_in_bytes); }
94 void remove_normal_array(const context& ctx);
96 template <typename T>
97 void set_line_width(const context& ctx, const T& line_width) { has_line_widths = true; ref_prog().set_attribute(ctx, get_prog_attribute_location(ctx, "line_width"), line_width); }
99 template <typename T>
100 void set_line_width_array(const context& ctx, const std::vector<T>& line_widths) { has_line_widths = true; set_attribute_array(ctx, "line_width", line_widths); }
102 template <typename T>
103 void set_line_width_array(const context& ctx, const T* line_widths, size_t nr_elements, unsigned stride_in_bytes = 0) { has_line_widths = true; set_attribute_array(ctx, "line_width", line_widths, nr_elements, stride_in_bytes); }
105 void remove_line_width_array(const context& ctx);
107 template <typename T>
108 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); }
110 template <typename T>
111 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); }
113 template <typename T>
114 void set_depth_offset_array(const context& ctx, const T* depth_offsets, size_t nr_elements, unsigned stride_in_bytes = 0) { has_depth_offsets = true; set_attribute_array(ctx, "depth_offset", depth_offsets, nr_elements, stride_in_bytes); }
116 void remove_depth_offset_array(const context& ctx);
118 void draw(context& ctx, size_t start, size_t count,
119 bool use_strips = false, bool use_adjacency = false, uint32_t strip_restart_index = -1);
120 };
122 extern CGV_API line_renderer& ref_line_renderer(context& ctx, int ref_count_change = 0);
125 {
126 bool self_reflect(cgv::reflect::reflection_handler& rh);
127 };
129 }
130}
131
132#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:621
abstract renderer class that provides functionality for grouping primitives
renderer that supports point splatting
void set_depth_offset_array(const context &ctx, const T *depth_offsets, size_t nr_elements, unsigned stride_in_bytes=0)
depth_offset array specifies box extends in case of position_is_center=true, otherwise the maximum po...
void set_normal_array(const context &ctx, const std::vector< T > &normals)
templated method to set the normal attribute from a vector of normals of type T, which should have 3 ...
void set_normal(const context &ctx, const cgv::math::fvec< T, 3 > &normal)
specify a single normal for all lines
void set_line_width_array(const context &ctx, const T *line_widths, size_t nr_elements, unsigned stride_in_bytes=0)
line_width array specifies box extends in case of position_is_center=true, otherwise the maximum poin...
void set_line_width(const context &ctx, const T &line_width)
specify a single line_width for all lines
void set_depth_offset(const context &ctx, const T &depth_offset)
specify a single depth_offset for all lines
void set_normal_array(const context &ctx, const T *normals, size_t nr_elements, unsigned stride_in_bytes=0)
templated method to set the normal attribute from an array of normals of type T, which should have 3 ...
void set_depth_offset_array(const context &ctx, const std::vector< T > &depth_offsets)
depth_offset array specifies box extends in case of position_is_center=true, otherwise the maximum po...
void set_line_width_array(const context &ctx, const std::vector< T > &line_widths)
line_width array specifies box extends in case of position_is_center=true, otherwise the maximum poin...
a shader program combines several shader code fragments to a complete definition of the shading pipel...
std::map< std::string, std::string > shader_define_map
typedef for shader define map data structure
Definition shader_code.h:52
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
float blend_width_in_pixel
blend with in pixels used for line smoothing
float default_depth_offset
default depth offset for case when "depth_offset" attribute is not set
float default_line_width
default line width for case when "line_width" attribute is not set
vec3 default_normal
default normal for case when "normal" attribute is not set
float halo_width_in_pixel
halo width in pixel
bool measure_line_width_in_pixel
whether to measure line width in pixels - otherwise in eye space relative to reference_line_width
float reference_line_width
reference line width multiplied to line width if measure_line_width_in_pixel is false
bool screen_aligned
whether to span line splat in screen aligned coordinate system
float halo_color_strength
parameter in [0,1] to mix line color with halo color
float percentual_halo_width
halo width in percent of line width
rgba default_color
default color for case when "color" attribute is not set
base class for all render styles
Definition renderer.h:16