1#include "slab_renderer.h"
2#include <cgv_gl/gl/gl.h>
3#include <cgv_gl/gl/gl_tools.h>
9 static int ref_count = 0;
26 tf_source_channel = 0;
79 ctx.
error(
"slab_renderer::enable() extent attribute not set");
113 glCullFace(GL_FRONT);
114 glEnable(GL_CULL_FACE);
128 glDisable(GL_CULL_FACE);
135 draw_impl(ctx, PT_POINTS, start, count,
false,
false, -1);
153#include <cgv/gui/provider.h>
161 void* value_ptr,
const std::string& value_type,
162 const std::string& gui_type,
const std::string& options,
bool*) {
172 p->
add_member_control(b,
"tf source channel", srs_ptr->tf_source_channel,
"value_slider",
"min=0;step=1;max=3;log=false;ticks=true");
175 p->
add_member_control(b,
"opacity scale", srs_ptr->
opacity,
"value_slider",
"min=0.0;step=0.0001;max=1.0;log=true;ticks=true");
178 p->
add_member_control(b,
"scale", srs_ptr->
scale,
"value_slider",
"min=0.0;step=0.0001;max=100.0;log=true;ticks=true");
185#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
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
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
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
bool validate_attributes(const context &ctx) const
check additionally the group attributes
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 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 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.
renderer that supports point splatting
bool has_extents
store whether extent array has been specified
bool has_texture_indices
whether array with per slab texture index has been specified
render_style * create_render_style() const
overload to allow instantiation of box_renderer
bool enable(context &ctx)
overload to activate group style
bool disable(context &ctx)
disable renderer
slab_renderer()
initializes position_is_center to true
bool has_translations
whether array with per slab translations has been specified
void set_position_is_center(bool _position_is_center)
set the flag, whether the position is interpreted as the slab center, true by default
bool position_is_center
whether position is slab center, if not it is lower left bottom corner
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 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 validate_attributes(const context &ctx) const
check additionally the group attributes
bool has_rotations
whether array with per slab rotations has been specified
bool build_shader_program(context &ctx, shader_program &prog, const shader_define_map &defines)
build slab program
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...
std::map< std::string, std::string > shader_define_map
typedef for shader define map data structure
slab_renderer & ref_slab_renderer(context &ctx, int ref_count_change)
reference to a singleton slab renderer that is 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 ...
base class for all render styles
float falloff_mix
overall influence of the falloff
float opacity
multiplied to the input opacity value during rendering to change the overall opacity of the slabs
float falloff_strength
strength of the opacity falloff in the slabs normal direction
int tf_tex_unit
unit used to access the volume transfer function texture, initialized to 1, must be a 1d texture
float step_size
constant step size for volume ray integration over all slabs
int tex_idx_offset
used to offset the texture index of each slab when specified
float scale
compensates for the overall slab scale
int tex_unit
unit used to access the slab texture values, initialized to 0, must point to a 2d texture array
slab_render_style()
construct with default values
bool use_transfer_function
whether to use a transfer function or interpret the luminance as alpha, initialized to false
float thickness_scale
multiplied to the thickness, initialized to 1
int tex_idx_stride
multiplied to the texture index of each slab
traits class with a static function get_name() of type const char* that returns the type name of the ...