1#include "surface_renderer.h"
2#include <cgv_gl/gl/gl.h>
3#include <cgv_gl/gl/gl_tools.h>
4#include <cgv_gl/gl/gl_context.h>
13 const auto& srs = get_style<surface_render_style>();
14 options.
define_macro(
"MAX_NR_LIGHTS", srs.max_nr_lights);
20 prog.allow_context_to_set_color(
false);
38 has_texcoords =
false;
42 remove_attribute_array(ctx,
"normal");
45 has_texcoords =
false;
46 remove_attribute_array(ctx,
"texcoord");
52 set_attribute_array(ctx,
"normal", element_type, vbo, offset_in_bytes, nr_elements, stride_in_bytes);
59 set_attribute_array(ctx,
"texcoord", element_type, vbo, offset_in_bytes, nr_elements, stride_in_bytes);
67 if (cull_per_primitive) {
91 if (cull_per_primitive) {
96 has_texcoords =
false;
119#include <cgv/gui/provider.h>
128 void* value_ptr,
const std::string& value_type,
129 const std::string& gui_type,
const std::string& options,
bool*)
138 "enums='Color Front=1,Color Back=2,Opacity Front=4,Opacity Back=8'");
168#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.
void push_cull_state()
push a copy of the current culling state onto the stack saved attributes: cull face enablement,...
virtual void set_material(const cgv::media::illum::surface_material &mat)
set the current material
virtual void set_cull_state(CullingMode culling_mode)
set the culling state
void pop_cull_state()
pop the top of the current culling state from the stack
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 update_shader_program_options(shader_compile_options &options) const override
overload to update the shader program compile options based on the current render style; only called ...
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
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
virtual bool build_shader_program(context &ctx, shader_program &prog, const shader_compile_options &options) const
overload to change default behaviour and build a custom shader program based on the passed options
bool has_colors
track whether color attribute is defined
bool attributes_persist() const
return whether attributes persist after a call to disable
Stores preprocessor options used for conditionally compiling shader programs.
void define_macro(const std::string &identifier)
Define a macro as identifier and no replacement text.
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...
void set_texcoord_array(const context &ctx, const std::vector< T > &texcoords)
templated method to set the texcoord attribute array from a vector of texcoords of type T
void set_normal_array(const context &ctx, const std::vector< T > &normals)
templated method to set the normal attribute array from a vector of normals of type T,...
void update_shader_program_options(shader_compile_options &options) const override
overload to update the shader program compile options based on the current render style; only called ...
bool build_shader_program(context &ctx, shader_program &prog, const shader_compile_options &options) const override
overload to disable context from setting color in shader program
void remove_normal_array(const context &ctx)
remove the normal attribute
void remove_texcoord_array(const context &ctx)
remove the texcoord attribute
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 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...
bool enable(context &ctx) override
overload to activate group style
bool disable(context &ctx) override
disable renderer
a vertex buffer is an unstructured memory block on the GPU.
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
CullingMode culling_mode
culling mode for point splats, defaults to CM_OFF
float surface_opacity
default value for the surface opacity when map color to material is used
int max_nr_lights
maximum number of supported lights (change triggers recompilation of shader)
ColorMapping map_color_to_material
material side[s] where color is to be mapped to the diffuse material component, defaults to CM_COLOR ...
IlluminationMode illumination_mode
illumination mode defaults to IM_ONE_SIDED
cgv::media::illum::textured_surface_material material
material of surface
cgv::media::illum::surface_material::color_type surface_color
default value for color when map color to material is used
compact type description of data that can be sent to the context; convertible to int
traits class with a static function get_name() of type const char* that returns the type name of the ...