1#include "line_renderer.h"
2#include <cgv_reflect_types/media/color.h>
3#include <cgv_gl/gl/gl.h>
4#include <cgv_gl/gl/gl_tools.h>
9 line_renderer& ref_line_renderer(context& ctx,
int ref_count_change)
11 static int ref_count = 0;
12 static line_renderer r;
23 has_line_widths =
true;
25 has_depth_offsets =
true;
32 has_line_widths =
false;
33 has_depth_offsets =
false;
37 remove_attribute_array(ctx,
"normal");
40 has_line_widths =
false;
41 remove_attribute_array(ctx,
"line_width");
44 has_depth_offsets =
false;
45 remove_attribute_array(ctx,
"depth_offset");
55 li = get_prog_attribute_location(ctx,
"normal",
false);
58 li = get_prog_attribute_location(ctx,
"depth_offset",
false);
61 li = get_prog_attribute_location(ctx,
"line_width",
false);
76 int li = get_prog_attribute_location(ctx,
"normal",
false);
80 if(!has_depth_offsets) {
81 int li = get_prog_attribute_location(ctx,
"depth_offset",
false);
85 if(!has_line_widths) {
86 int li = get_prog_attribute_location(ctx,
"line_width",
false);
115 has_line_widths =
false;
116 has_depth_offsets =
false;
126 draw_impl(ctx, use_strips ? (use_adjacency ? PT_LINE_STRIP_ADJACENCY : PT_LINE_STRIP) : (use_adjacency ? PT_LINES_ADJACENCY : PT_LINES), start, count, use_strips, use_adjacency, strip_restart_index);
155#include <cgv/gui/provider.h>
164 void* value_ptr,
const std::string& value_type,
165 const std::string& gui_type,
const std::string& options,
bool*)
171 p->
add_gui(
"Default Normal", lrs_ptr->
default_normal,
"direction",
"options='min=-1;max=1;ticks=true'");
200#include "gl/lib_begin.h"
base class for all classes that can be registered with support for dynamic properties (see also secti...
helper template for registration of gui creators
derive from this class to provide a gui to the current viewer
bool add_gui(const std::string &label, T &value, const std::string &gui_type="", const std::string &options="")
Add a composed gui of the given gui_type for the given value.
void align(const std::string &_align)
send pure alignment information
bool begin_tree_node(const std::string &label, const T &value, bool initial_visibility=false, const std::string &options="", gui_group_ptr ggp=gui_group_ptr())
Begin a sub tree of a tree structured gui.
data::ref_ptr< control< T > > add_member_control(cgv::base::base *base_ptr, const std::string &label, T &value, const std::string &gui_type="", const std::string &options="", const std::string &align="\n")
add control with callback to cgv::base::on_set method on cgv::gui::control::value_change
void end_tree_node(const T &value)
template specialization that allows to specify value reference plus node_instance by using the result...
the self reflection handler is passed to the virtual self_reflect() method of cgv::base::base.
bool reflect_base(B &base_ref)
reflect a base class with its members
bool reflect_member(const std::string &member_name, T &member_ref, bool hard_cast=false)
call this to reflect a member by member name and reference to the member.
attribute array manager used to upload arrays to gpu
base class for all drawables, which is independent of the used rendering API.
virtual void set_blend_func(BlendFunction src_factor, BlendFunction dst_factor)
set the blend function
virtual void set_color(const rgba &clr)
set the current color
void push_blend_state()
push a copy of the current blend state onto the stack saved attributes: blend enablement,...
void pop_blend_state()
pop the top of the current culling state from the stack
virtual unsigned int get_height() const =0
return the height of the window
BlendState get_blend_state() const
return the current blend state
virtual void enable_blending()
enable blending
bool disable(context &ctx)
disable renderer
void enable_attribute_array_manager(const context &ctx, attribute_array_manager &aam)
call this before setting attribute arrays to manage attribute array in given manager
void disable_attribute_array_manager(const context &ctx, attribute_array_manager &aam)
call this after last render/draw call to ensure that no other users of renderer change attribute arra...
bool enable(context &ctx)
overload to activate group style
void draw(context &ctx, size_t start, size_t count, bool use_strips=false, bool use_adjacency=false, uint32_t strip_restart_index=-1) override
convenience function to render with default settings
bool init(context &ctx) override
call init() once before using renderer
void remove_depth_offset_array(const context &ctx)
remove the depth offset attribute
void remove_normal_array(const context &ctx)
remove the normal attribute
bool enable(context &ctx) override
overload to activate group style
bool disable(context &ctx) override
disable renderer
void remove_line_width_array(const context &ctx)
remove the line width attribute
void disable_attribute_array_manager(const context &ctx, attribute_array_manager &aam) override
call this after last render/draw call to ensure that no other users of renderer change attribute arra...
void enable_attribute_array_manager(const context &ctx, attribute_array_manager &aam) override
call this before setting attribute arrays to manage attribute array in given manager
void manage_singleton(context &ctx, const std::string &renderer_name, int &ref_count, int ref_count_change)
used by derived classes to manage singletons
bool has_attribute(const context &ctx, const std::string &name)
check for attribute
virtual bool init(context &ctx)
call init() once before using renderer
shader_program & ref_prog()
derived renderer classes have access to shader program
bool has_colors
track whether color attribute is defined
bool attributes_persist() const
return whether attributes persist after a call to disable
void draw_impl(context &ctx, PrimitiveType pt, size_t start, size_t count, bool use_strips=false, bool use_adjacency=false, uint32_t strip_restart_index=-1)
default implementation of draw method with support for indexed rendering and different primitive type...
bool set_uniform(const context &ctx, const std::string &name, const T &value, bool generate_error=false)
Set the value of a uniform by name, where the type can be any of int, unsigned, float,...
bool set_attribute(const context &ctx, const std::string &name, const T &value)
set constant default value of a vertex attribute by attribute name, if name does not specify an attri...
cgv::math::fvec< float, 3 > vec3
declare type of 3d single precision floating point vectors
interface for gui creators
bool create(provider *p, const std::string &label, void *value_ptr, const std::string &value_type, const std::string &gui_type, const std::string &options, bool *)
attempt to create a gui and return whether this was successful
this reflection traits implementation is used for external self_reflect implementations of instances ...
render style used for group information
bool use_group_color
whether to use group colors indexed through group index, defaults to false
rgba halo_color
halo color
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
bool blend_lines
whether to enable blending while rendering (needed for smooth edges; true by default)
traits class with a static function get_name() of type const char* that returns the type name of the ...