1#include "surfel_renderer.h"
2#include <cgv_gl/gl/gl.h>
3#include <cgv_gl/gl/gl_tools.h>
9 static int ref_count = 0;
38 has_point_sizes =
true;
40 has_indexed_colors =
true;
46 has_point_sizes =
false;
47 has_indexed_colors =
false;
50 has_point_sizes =
false;
51 remove_attribute_array(ctx,
"point_size");
54 has_indexed_colors =
false;
55 remove_attribute_array(ctx,
"indexed_color");
57 surfel_renderer::surfel_renderer()
59 has_point_sizes =
false;
60 has_group_point_sizes =
false;
61 has_indexed_colors =
false;
63 reference_point_size = 0.01f;
66 void surfel_renderer::set_reference_point_size(
float _reference_point_size)
68 reference_point_size = _reference_point_size;
70 void surfel_renderer::set_y_view_angle(
float _y_view_angle)
72 y_view_angle = _y_view_angle;
83 if (has_indexed_colors) {
85 ctx.
error(
"surfel_renderer::validate_attributes() both point color and color index attributes set, using color index");
97 ctx.
error(
"surfel_renderer::validate_attributes() group_point_sizes not set");
119 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
124 if (!has_point_sizes)
131 float pixel_extent_per_depth = (float)(2.0*tan(0.5*0.0174532925199*y_view_angle) / ctx.
get_height());
150 glDisable(GL_CULL_FACE);
153 has_indexed_colors =
false;
154 has_point_sizes =
false;
161 draw_impl(ctx, PT_POINTS, start, count,
false,
false, -1);
187#include <cgv/gui/provider.h>
196 void* value_ptr,
const std::string& value_type,
197 const std::string& gui_type,
const std::string& options,
bool*)
236#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 error(const std::string &message, const render_component *rc=0) const
error handling
virtual unsigned int get_height() const =0
return the height of the window
bool validate_attributes(const context &ctx) const
check additionally the group attributes
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
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...
a shader program combines several shader code fragments to a complete definition of the shading pipel...
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...
bool build_program(const context &ctx, const std::string &file_name, bool show_error=false, const shader_define_map &defines=shader_define_map())
successively calls create, attach_program and link.
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...
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
bool disable(context &ctx)
disable renderer
bool enable(context &ctx)
overload to activate group style
renderer that supports point splatting
render_style * create_render_style() const
overload to allow instantiation of surfel_renderer
void draw(context &ctx, size_t start, size_t count, bool use_strips=false, bool use_adjacency=false, uint32_t strip_restart_index=-1)
convenience function to render with default settings
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
bool enable(context &ctx)
overload to activate group style
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...
void remove_point_size_array(const context &ctx)
remove the point size attribute
bool disable(context &ctx)
disable renderer
bool validate_attributes(const context &ctx) const
check additionally the group attributes
void remove_indexed_color_array(const context &ctx)
remove the indexed color attribute
bool build_shader_program(context &ctx, shader_program &prog, const shader_define_map &defines)
build surfel program
std::map< std::string, std::string > shader_define_map
typedef for shader define map data structure
surfel_renderer & ref_surfel_renderer(context &ctx, int ref_count_change)
reference to a singleton surfel renderer that can be shared among drawables
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 ...
bool use_group_color
whether to use group colors indexed through group index, defaults to false
base class for all render styles
CullingMode culling_mode
culling mode for point splats, set to CM_OFF in constructor
float percentual_halo_width
set to 0 in constructor
float point_size
default value assigned to point size attribute in enable method of point renderer,...
bool measure_point_size_in_pixel
whether to measure point size in pixels or in world space relative to reference_pixel_size passed to ...
float surface_offset
position offset in normal direction to prevent z-figthing if surfels are placed directly on flat surf...
bool use_group_point_size
whether to use the
bool orient_splats
set to true in constructor
float halo_width_in_pixel
set to 0 in constructor
float blend_width_in_pixel
set to 1 in constructor
bool blend_points
set to false in constructor
surfel_render_style()
construct with default values
rgba halo_color
color of halo with opacity channel
float halo_color_strength
strength in [0,1] of halo color with respect to color of primitive
traits class with a static function get_name() of type const char* that returns the type name of the ...