1#include "box_renderer.h"
2#include <cgv_gl/gl/gl.h>
3#include <cgv_gl/gl/gl_tools.h>
16 static int ref_count = 0;
63 remove_attribute_array(ctx,
"extent");
67 remove_attribute_array(ctx,
"radius");
71 remove_attribute_array(ctx,
"secondary_color");
75 remove_attribute_array(ctx,
"translation");
79 remove_attribute_array(ctx,
"rotation");
101 const auto& brs = get_style<box_render_style>();
102 if (
ref_prog().get_uniform_location(ctx,
"default_radius") != -1)
104 if (
ref_prog().get_uniform_location(ctx,
"relative_anchor") != -1)
126 draw_impl(ctx, PT_POINTS, start, count,
false,
false, -1);
141 shader_code::set_define(defines,
"ROUNDING", brs.
rounding,
false);
150#include <cgv/gui/provider.h>
159 void* value_ptr,
const std::string& value_type,
160 const std::string& gui_type,
const std::string& options,
bool*)
179#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.
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
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
renderer that supports point splatting
bool disable(context &ctx)
disable renderer
render_style * create_render_style() const
overload to allow instantiation of box_renderer
bool has_translations
whether array with per box translations has been specified
box_renderer()
initializes position_is_center to true
void remove_translation_array(const context &ctx)
remove the translation attribute
bool build_shader_program(context &ctx, shader_program &prog, const shader_define_map &defines)
build box program
bool has_rotations
whether array with per box rotations has been specified
void update_defines(shader_define_map &defines)
overload to update the shader defines based on the current render style; only called if internal shad...
void remove_extent_array(const context &ctx)
remove the extent attribute
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_secondary_color_array(const context &ctx)
remove the secondary color attribute
void draw(context &ctx, size_t start, size_t count, bool use_strips=false, bool use_adjacency=false, uint32_t strip_restart_index=-1)
Draw a range of vertices or indexed elements.
bool has_radii
store whether extent array has been specified
bool enable(context &ctx)
enable box 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
bool has_secondary_colors
whether secondary color or color array was set
bool position_is_center
whether position is box center, if not it is lower left bottom corner
void set_position_is_center(bool _position_is_center)
set the flag, whether the position is interpreted as the box center, true by default
void remove_rotation_array(const context &ctx)
remove the rotation attribute
void remove_radius_array(const context &ctx)
remove the radius attribute
bool has_extents
store whether extent array has been specified
base class for all drawables, which is independent of the used rendering API.
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 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
std::map< std::string, std::string > shader_define_map
typedef for shader define map data structure
box_renderer & ref_box_renderer(context &ctx, int ref_count_change)
reference to a singleton box renderer that is shared among drawables
cgv::math::fvec< float, 3 > vec3
declare type of 3d single precision floating point vectors
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
interface for gui creators
this reflection traits implementation is used for external self_reflect implementations of instances ...
boxes use surface render styles
vec3 default_extent
extent used in case extent array is not specified
vec3 relative_anchor
box anchor position relative to center that corresponds to the position attribute
box_render_style()
default constructor sets default extent to (1,1,1) and relative anchor to (0,0,0)
bool rounding
whether to use rounding of edges and corners (enabling re-compiles shader program)
float default_radius
radius used in case radius array is not specified
base class for all render styles
traits class with a static function get_name() of type const char* that returns the type name of the ...