cgv
Loading...
Searching...
No Matches
cgv::render::shader_program Class Reference

a shader program combines several shader code fragments to a complete definition of the shading pipeline. More...

#include <shader_program.h>

Inheritance diagram for cgv::render::shader_program:
cgv::render::shader_program_base cgv::render::render_component

Public Member Functions

 shader_program (bool _show_code_errors=false)
 create empty shader program and set the option whether errors during shader code attachment should be printed to std::cerr
 ~shader_program ()
 call destruct method
bool create (const context &ctx)
 create the shader program
void destruct (const context &ctx)
 destruct shader program
bool attach_code (const context &ctx, const shader_code &code)
 attach a compiled shader code instance that is managed outside of program
bool detach_code (const context &ctx, const shader_code &code)
 detach a shader code
bool attach_code (const context &ctx, const std::string &source, ShaderType st)
 attach a shader code given as string and managed the created shader code object
bool attach_file (const context &ctx, const std::string &file_name, ShaderType st=ST_DETECT, const shader_compile_options &options={})
 read shader code from file, compile and attach to program
bool attach_files (const context &ctx, const std::string &base_name, const shader_compile_options &options={})
 read shader code from files with the given base name, compile and attach them
bool attach_dir (const context &ctx, const std::string &dir_name, bool recursive, const shader_compile_options &options={})
 collect shader code files from directory, compile and attach.
bool attach_program (const context &ctx, std::string file_name, bool show_error=false, const shader_compile_options &options={})
 collect shader code files declared in shader program file, compile and attach them
bool link (const context &ctx, bool show_error=false)
 link shaders to an executable program
bool is_linked () const
 return whether program is linked
void inspect_program_variables (const context &ctx, cgv::render::ProgramVariableKind kind, std::vector< cgv::render::program_variable_info > &Vs, bool get_location=true, bool get_value=true)
 retrieve information on all uniform or attribute variables of a shader program
bool build_files (const context &ctx, const std::string &base_name, bool show_error=false)
 successively calls create, attach_files and link.
bool build_dir (const context &ctx, const std::string &dir_name, bool recursive=false, bool show_error=false)
 successively calls create, attach_dir and link.
bool build_program (const context &ctx, const std::string &file_name, bool show_error=false)
 successively calls create, attach_program and link.
bool build_files (const context &ctx, const std::string &base_name, const shader_compile_options &options, bool show_error=false)
 successively calls create, attach_files and link.
bool build_dir (const context &ctx, const std::string &dir_name, const shader_compile_options &options, bool recursive=false, bool show_error=false)
 successively calls create, attach_dir and link.
bool build_program (const context &ctx, const std::string &file_name, const shader_compile_options &options, bool show_error=false)
 successively calls create, attach_program and link.
void set_geometry_shader_info (PrimitiveType input_type, PrimitiveType output_type, int max_output_count=0)
 configure the geometry shader, if count < 1 set it to get_max_nr_geometry_shader_output_vertices
bool enable (context &ctx)
 enable the shader program
bool disable (context &ctx)
 disable shader program and restore fixed functionality
bool is_enabled () const
 check whether program is currently enabled
const std::map< std::string, int > & get_uniform_locations () const
 return uniform name and location pairs
int get_uniform_location (const context &ctx, const std::string &name) const
 query location index of an uniform
bool set_material_uniform (const context &ctx, const std::string &name, const cgv::media::illum::surface_material &material, bool generate_error=false)
 set a uniform of type material
bool set_textured_material_uniform (const context &ctx, const std::string &name, const textured_material &material, bool generate_error=false)
 set a uniform of type textured_material
bool set_light_uniform (const context &ctx, const std::string &name, const cgv::media::illum::light_source &light, bool generate_error=false)
 set a uniform of type light source
template<typename T>
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, vec<int>, vec<unsigned>, vec<float>, mat<float> and the vectors are of dimension 2, 3 or 4 and the matrices of dimensions 2, 3 or 4.
template<typename T>
bool set_uniform_array (const context &ctx, const std::string &name, const T &array)
 set uniform array from array array where number elements can be derived from array through array_descriptor_traits; supported array types include cgv::math::vec and std::vector
template<typename T>
bool set_uniform_array (const context &ctx, const std::string &name, const T *array, size_t nr_elements, bool generate_error=false)
 set uniform array from an array with nr_elements elements of type T pointed to by array
template<typename T>
bool set_uniform (const context &ctx, int loc, const T &value)
 Set the value of a uniform by location, where the type can be any of int, unsigned, float, vec<int>, vec<unsigned>, vec<float>, mat<float> and the vectors are of dimension 2, 3 or 4 and the matrices of dimensions 2, 3 or 4.
template<typename T>
bool set_uniform_array (const context &ctx, int loc, const T &array)
 set uniform array from array array where number elements can be derived from array through array_descriptor_traits; supported array types include cgv::math::vec and std::vector
template<typename T>
bool set_uniform_array (const context &ctx, int loc, const T *array, size_t nr_elements)
 set uniform array from an array with nr_elements elements of type T pointed to by array
bool set_uniform (const context &ctx, int loc, type_descriptor value_type, const void *value_ptr)
 Set the value of a uniform by location, where the value is defined by a type descriptor and address.
int get_uniform_block_index (const context &ctx, const std::string &name) const
bool set_uniform_block_binding (const context &ctx, int index, int binding)
bool set_uniform_block_binding (const context &ctx, const std::string &name, int binding)
int get_attribute_location (const context &ctx, const std::string &name) const
 query location index of an attribute
template<typename T>
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 attribute, an error message is generated
template<typename T>
bool set_attribute (const context &ctx, int loc, const T &value)
 set constant default value of a vertex attribute by location index
Public Member Functions inherited from cgv::render::shader_program_base
 shader_program_base ()
 initializes members
void specify_standard_uniforms (bool view, bool material, bool lights, bool gamma)
void specify_standard_vertex_attribute_names (context &ctx, bool color=true, bool normal=true, bool texcoord=true)
void specify_vertex_attribute_names (context &ctx, const std::string &position, const std::string &color="", const std::string &normal="", const std::string &texcoord="")
bool does_use_view () const
bool does_use_material () const
bool does_use_lights () const
bool does_use_gamma () const
void allow_context_to_set_color (bool allow)
int get_position_index () const
int get_color_index () const
bool does_context_set_color () const
int get_normal_index () const
int get_texcoord_index () const
Public Member Functions inherited from cgv::render::render_component
 render_component ()
 initialize members
virtual bool is_created () const
 return whether component has been created
void put_id_void (void *ptr) const
 copy the rendering api specific id the component to the memory location of the given pointer.
template<typename T>
void put_id (T &id) const
 cast the refence to rendering api specific representation of component id to the specified type

Static Public Member Functions

static bool collect_files_from_cache (const std::string &name, std::vector< std::string > &file_names, bool &added_files)
 resolve file name with shader_code::find_file and add file to list if found
static bool collect_file (const std::string &file_name, bool use_cache, std::vector< std::string > &file_names)
 resolve file name with shader_code::find_file and add file to list if found
static bool collect_files (const std::string &base_name, bool use_cache, std::vector< std::string > &file_names)
 collect shader code files that extent the given base name.
static bool collect_dir (const std::string &dir_name, bool recursive, std::vector< std::string > &file_names)
 collect shader code files from directory.
static bool collect_program (const std::string &file_name, bool use_cache, std::vector< std::string > &file_names)
 collect shader code files declared in a shader program file.
static unsigned int get_max_nr_geometry_shader_output_vertices (const context &ctx)
 return the maximum number of output vertices of a geometry shader
static std::vector< shader_compile_options > extract_instances (std::string file_name)
 find and parse all instance definitions in a shader program file

Protected Member Functions

bool attach_files (const context &ctx, const std::vector< std::string > &file_names, const shader_compile_options &options={})
 attach a list of files
void update_state (const context &ctx)
 ensure that the state has been set in the context

Static Protected Member Functions

static bool open_program_file (std::string &file_name, bool use_cache, std::string &content, std::vector< cgv::utils::line > &lines, std::string *last_error_ptr=0)
 common code necessary to open file

Protected Attributes

bool show_code_errors: 1
bool linked: 1
bool state_out_of_date: 1
int nr_attached_geometry_shaders: 13
Protected Attributes inherited from cgv::render::shader_program_base
bool is_enabled
bool auto_detect_uniforms
bool auto_detect_vertex_attributes
bool uses_view
bool uses_material
bool uses_lights
bool uses_gamma
std::map< std::string, int > uniform_locations
int position_index
int color_index
bool context_sets_color
int normal_index
int texcoord_index

Static Protected Attributes

static std::map< std::string, std::string > program_file_cache
 maps used to cache program file contents and valid file names indexed by their respective file name
static std::map< std::string, std::vector< std::string > > files_cache

Additional Inherited Members

Public Attributes inherited from cgv::render::shader_program_base
PrimitiveType geometry_shader_input_type
PrimitiveType geometry_shader_output_type
int geometry_shader_output_count
Public Attributes inherited from cgv::render::render_component
void * handle
void * internal_format
void * user_data
const context * ctx_ptr
 keep pointer to my context
std::string last_error
 a string that contains the last error

Detailed Description

a shader program combines several shader code fragments to a complete definition of the shading pipeline.

Definition at line 28 of file shader_program.h.

Constructor & Destructor Documentation

◆ shader_program()

cgv::render::shader_program::shader_program ( bool _show_code_errors = false)

create empty shader program and set the option whether errors during shader code attachment should be printed to std::cerr

create empty shader program

Definition at line 187 of file shader_program.cxx.

◆ ~shader_program()

cgv::render::shader_program::~shader_program ( )

call destruct method

Definition at line 196 of file shader_program.cxx.

References cgv::render::render_component::ctx_ptr, and destruct().

Member Function Documentation

◆ attach_code() [1/2]

bool cgv::render::shader_program::attach_code ( const context & ctx,
const shader_code & code )

◆ attach_code() [2/2]

bool cgv::render::shader_program::attach_code ( const context & ctx,
const std::string & source,
ShaderType st )

attach a shader code given as string and managed the created shader code object

Definition at line 258 of file shader_program.cxx.

References attach_code(), cgv::render::shader_code::compile(), cgv::render::render_component::last_error, and cgv::render::shader_code::set_code().

◆ attach_dir()

bool cgv::render::shader_program::attach_dir ( const context & ctx,
const std::string & dir_name,
bool recursive,
const shader_compile_options & options = {} )

collect shader code files from directory, compile and attach.

Definition at line 304 of file shader_program.cxx.

References attach_files(), and collect_dir().

Referenced by attach_program(), and build_dir().

◆ attach_file()

bool cgv::render::shader_program::attach_file ( const context & ctx,
const std::string & file_name,
ShaderType st = ST_DETECT,
const shader_compile_options & options = {} )

read shader code from file, compile and attach to program

Definition at line 278 of file shader_program.cxx.

References attach_code(), cgv::render::render_component::last_error, and cgv::render::shader_code::read_and_compile().

Referenced by attach_files(), and attach_program().

◆ attach_files() [1/2]

bool cgv::render::shader_program::attach_files ( const context & ctx,
const std::string & base_name,
const shader_compile_options & options = {} )

read shader code from files with the given base name, compile and attach them

Definition at line 297 of file shader_program.cxx.

References attach_files(), collect_files(), and cgv::render::context::is_shader_file_cache_enabled().

◆ attach_files() [2/2]

bool cgv::render::shader_program::attach_files ( const context & ctx,
const std::vector< std::string > & file_names,
const shader_compile_options & options = {} )
protected

attach a list of files

Definition at line 26 of file shader_program.cxx.

References attach_file(), and cgv::render::render_component::last_error.

Referenced by attach_dir(), attach_files(), attach_program(), and build_files().

◆ attach_program()

bool cgv::render::shader_program::attach_program ( const context & ctx,
std::string file_name,
bool show_error = false,
const shader_compile_options & options = {} )

◆ build_dir() [1/2]

bool cgv::render::shader_program::build_dir ( const context & ctx,
const std::string & dir_name,
bool recursive = false,
bool show_error = false )

successively calls create, attach_dir and link.

Definition at line 505 of file shader_program.cxx.

References build_dir().

Referenced by build_dir().

◆ build_dir() [2/2]

bool cgv::render::shader_program::build_dir ( const context & ctx,
const std::string & dir_name,
const shader_compile_options & options,
bool recursive = false,
bool show_error = false )

successively calls create, attach_dir and link.

Definition at line 520 of file shader_program.cxx.

References attach_dir(), create(), cgv::render::render_component::is_created(), and link().

◆ build_files() [1/2]

bool cgv::render::shader_program::build_files ( const context & ctx,
const std::string & base_name,
bool show_error = false )

successively calls create, attach_files and link.

Definition at line 500 of file shader_program.cxx.

References build_files().

Referenced by build_files().

◆ build_files() [2/2]

bool cgv::render::shader_program::build_files ( const context & ctx,
const std::string & base_name,
const shader_compile_options & options,
bool show_error = false )

successively calls create, attach_files and link.

Definition at line 515 of file shader_program.cxx.

References attach_files(), create(), cgv::render::render_component::is_created(), and link().

◆ build_program() [1/2]

bool cgv::render::shader_program::build_program ( const context & ctx,
const std::string & file_name,
bool show_error = false )

successively calls create, attach_program and link.

Definition at line 510 of file shader_program.cxx.

References build_program().

Referenced by build_program().

◆ build_program() [2/2]

bool cgv::render::shader_program::build_program ( const context & ctx,
const std::string & file_name,
const shader_compile_options & options,
bool show_error = false )

◆ collect_dir()

bool cgv::render::shader_program::collect_dir ( const std::string & dir_name,
bool recursive,
std::vector< std::string > & file_names )
static

collect shader code files from directory.

If the directory does not exist search it in the shader path of the shader configuration returned by get_shader_config(). Returns true if at least one shader code file has been collected.

Definition at line 113 of file shader_program.cxx.

References cgv::data::ref_ptr< T, is_ref_counted >::empty(), and cgv::render::get_shader_config().

Referenced by attach_dir(), and collect_program().

◆ collect_file()

bool cgv::render::shader_program::collect_file ( const std::string & file_name,
bool use_cache,
std::vector< std::string > & file_names )
static

resolve file name with shader_code::find_file and add file to list if found

Definition at line 53 of file shader_program.cxx.

References collect_files_from_cache(), and cgv::render::shader_code::find_file().

Referenced by collect_program().

◆ collect_files()

bool cgv::render::shader_program::collect_files ( const std::string & base_name,
bool use_cache,
std::vector< std::string > & file_names )
static

collect shader code files that extent the given base name.

Returns true if at least one shader code file has been collected.

Definition at line 79 of file shader_program.cxx.

References collect_files_from_cache(), and cgv::render::shader_code::find_file().

Referenced by attach_files(), and collect_program().

◆ collect_files_from_cache()

bool cgv::render::shader_program::collect_files_from_cache ( const std::string & name,
std::vector< std::string > & file_names,
bool & added_files )
static

resolve file name with shader_code::find_file and add file to list if found

Definition at line 37 of file shader_program.cxx.

Referenced by collect_file(), and collect_files().

◆ collect_program()

bool cgv::render::shader_program::collect_program ( const std::string & file_name,
bool use_cache,
std::vector< std::string > & file_names )
static

collect shader code files declared in a shader program file.

Program files have the extension glpr and contain lines of the form command:argument. The following commands can be used

  • file:file_name ... calls attach_file(ctx,file_name)
  • vertex_file:file_name ... calls attach_file(ctx,file_name,ST_VERTEX)
  • geometry_file:file_name ... calls attach_file(ctx,file_name,ST_GEOMETRY)
  • fragment_file:file_name ... calls attach_file(ctx,file_name,ST_FRAGMENT)
  • files:base_name ... calls attach_files(ctx,base_name)
  • dir:dir_name ... calls attach_dir(ctx,dir_name,false)
  • rec_dir:dir_name ... calls attach_dir(ctx,dir_name,true)
  • program:file_name ... calls attach_program(file_name) recursively take care, not to generate cyclic includes.
  • geometry_shader_info:input_type;output_type;max_output_count ... calls set_geometry_shader_info with input_type, output_type and max_output_count as arguments, where the primitive types are one out of points,lines,lines_adjacency,line_strip,line_strip_adjacency,line_loop, triangles,triangles_adjacency,triangle_strip,triangle_strip_adjacency,triangle_fan, quads,quad_strip,polygon. Returns true if at least one shader code file has been collected.

Definition at line 135 of file shader_program.cxx.

References collect_dir(), collect_file(), collect_files(), collect_program(), cgv::render::shader_code::decode_if_base64(), cgv::render::shader_code::find_file(), cgv::render::get_shader_config(), cgv::base::read_data_file(), cgv::utils::split_to_lines(), and cgv::render::to_string().

Referenced by collect_program().

◆ create()

bool cgv::render::shader_program::create ( const context & ctx)

create the shader program

Definition at line 206 of file shader_program.cxx.

References cgv::render::render_component::ctx_ptr, and destruct().

Referenced by build_dir(), build_files(), and build_program().

◆ destruct()

void cgv::render::shader_program::destruct ( const context & ctx)

destruct shader program

Definition at line 744 of file shader_program.cxx.

Referenced by create(), and ~shader_program().

◆ detach_code()

bool cgv::render::shader_program::detach_code ( const context & ctx,
const shader_code & code )

detach a shader code

Definition at line 241 of file shader_program.cxx.

References cgv::render::shader_code::get_shader_type(), and cgv::render::render_component::last_error.

◆ disable()

bool cgv::render::shader_program::disable ( context & ctx)

◆ enable()

◆ extract_instances()

std::vector< shader_compile_options > cgv::render::shader_program::extract_instances ( std::string file_name)
static

◆ get_attribute_location()

int cgv::render::shader_program::get_attribute_location ( const context & ctx,
const std::string & name ) const

◆ get_max_nr_geometry_shader_output_vertices()

unsigned int cgv::render::shader_program::get_max_nr_geometry_shader_output_vertices ( const context & ctx)
static

return the maximum number of output vertices of a geometry shader

Definition at line 551 of file shader_program.cxx.

References cgv::render::device_capabilities::max_geometry_shader_output_vertex_count.

Referenced by update_state().

◆ get_uniform_block_index()

int cgv::render::shader_program::get_uniform_block_index ( const context & ctx,
const std::string & name ) const

Definition at line 717 of file shader_program.cxx.

◆ get_uniform_location()

int cgv::render::shader_program::get_uniform_location ( const context & ctx,
const std::string & name ) const

◆ get_uniform_locations()

const std::map< std::string, int > & cgv::render::shader_program::get_uniform_locations ( ) const

return uniform name and location pairs

Definition at line 635 of file shader_program.cxx.

◆ inspect_program_variables()

void cgv::render::shader_program::inspect_program_variables ( const context & ctx,
cgv::render::ProgramVariableKind kind,
std::vector< cgv::render::program_variable_info > & Vs,
bool get_location = true,
bool get_value = true )

retrieve information on all uniform or attribute variables of a shader program

Parameters
ctxrender context
kindenum specifying whether uniforms or attributes are queried
Vsresulting list of program variable infos
get_locationwhether to retrieve program locations of variables
get_valuewhether to retrieve current values of program variables

Definition at line 19 of file shader_program.cxx.

◆ is_enabled()

bool cgv::render::shader_program::is_enabled ( ) const
inline

check whether program is currently enabled

Definition at line 142 of file shader_program.h.

Referenced by cgv::render::gl::cover_screen(), disable(), enable(), and cgv::render::color_scale_adapter::set_uniforms_in_program().

◆ is_linked()

bool cgv::render::shader_program::is_linked ( ) const

return whether program is linked

Definition at line 586 of file shader_program.cxx.

Referenced by enable().

◆ link()

bool cgv::render::shader_program::link ( const context & ctx,
bool show_error = false )

◆ open_program_file()

bool cgv::render::shader_program::open_program_file ( std::string & file_name,
bool use_cache,
std::string & content,
std::vector< cgv::utils::line > & lines,
std::string * last_error_ptr = 0 )
staticprotected

◆ set_attribute() [1/2]

◆ set_attribute() [2/2]

template<typename T>
bool cgv::render::shader_program::set_attribute ( const context & ctx,
int loc,
const T & value )
inline

set constant default value of a vertex attribute by location index

Definition at line 230 of file shader_program.h.

References cgv::render::context::error().

◆ set_geometry_shader_info()

void cgv::render::shader_program::set_geometry_shader_info ( PrimitiveType input_type,
PrimitiveType output_type,
int max_output_count = 0 )

configure the geometry shader, if count < 1 set it to get_max_nr_geometry_shader_output_vertices

configure the geometry shader

Definition at line 592 of file shader_program.cxx.

Referenced by attach_program().

◆ set_light_uniform()

bool cgv::render::shader_program::set_light_uniform ( const context & ctx,
const std::string & name,
const cgv::media::illum::light_source & light,
bool generate_error = false )

set a uniform of type light source

Definition at line 692 of file shader_program.cxx.

References set_uniform().

Referenced by cgv::render::context::set_current_lights().

◆ set_material_uniform()

◆ set_textured_material_uniform()

◆ set_uniform() [1/3]

template<typename T>
bool cgv::render::shader_program::set_uniform ( const context & ctx,
const std::string & name,
const T & value,
bool generate_error = false )
inline

Set the value of a uniform by name, where the type can be any of int, unsigned, float, vec<int>, vec<unsigned>, vec<float>, mat<float> and the vectors are of dimension 2, 3 or 4 and the matrices of dimensions 2, 3 or 4.

Definition at line 157 of file shader_program.h.

References cgv::render::context::error(), and get_uniform_location().

Referenced by vr::configure_seethrough_shader_program(), cgv::render::render_info::draw(), vr_test::draw(), cgv::render::a_buffer::enable(), cgv::render::arrow_renderer::enable(), cgv::render::box_renderer::enable(), cgv::render::box_wire_renderer::enable(), cgv::render::cone_renderer::enable(), cgv::render::ellipsoid_renderer::enable(), cgv::render::group_renderer::enable(), cgv::render::line_renderer::enable(), cgv::render::normal_renderer::enable(), cgv::render::point_renderer::enable(), cgv::render::rectangle_renderer::enable(), cgv::render::sphere_renderer::enable(), cgv::render::spline_tube_renderer::enable(), cgv::render::surface_renderer::enable(), cgv::render::surfel_renderer::enable(), cgv::render::volume_renderer::enable(), vr_test::finish_draw(), cgv::render::gl::render_to_texture3D(), cgv::render::context::set_current_gamma(), cgv::render::context::set_current_lights(), cgv::render::context::set_current_view(), set_light_uniform(), cgv::render::gl::set_lighting_parameters(), set_material_uniform(), cgv::plot::plot_base::set_plot_uniforms(), set_textured_material_uniform(), and cgv::render::color_scale_adapter::set_uniforms_in_program().

◆ set_uniform() [2/3]

template<typename T>
bool cgv::render::shader_program::set_uniform ( const context & ctx,
int loc,
const T & value )
inline

Set the value of a uniform by location, where the type can be any of int, unsigned, float, vec<int>, vec<unsigned>, vec<float>, mat<float> and the vectors are of dimension 2, 3 or 4 and the matrices of dimensions 2, 3 or 4.

Definition at line 191 of file shader_program.h.

◆ set_uniform() [3/3]

bool cgv::render::shader_program::set_uniform ( const context & ctx,
int loc,
type_descriptor value_type,
const void * value_ptr )
inline

Set the value of a uniform by location, where the value is defined by a type descriptor and address.

The value type descriptor can be equivalent to any of int, unsigned, float, vec<int>, vec<unsigned>, vec<float>, mat<float> and the vectors are of dimension 2, 3 or 4 and the matrices of dimensions 2, 3 or 4.

Definition at line 207 of file shader_program.h.

◆ set_uniform_array() [1/4]

template<typename T>
bool cgv::render::shader_program::set_uniform_array ( const context & ctx,
const std::string & name,
const T & array )
inline

set uniform array from array array where number elements can be derived from array through array_descriptor_traits; supported array types include cgv::math::vec and std::vector

Definition at line 168 of file shader_program.h.

References cgv::render::context::error(), and get_uniform_location().

Referenced by cgv::render::cone_renderer::enable(), cgv::render::gl::set_lighting_parameters(), cgv::plot::plot_base::set_mapping_uniforms(), and cgv::plot::plot_base::set_plot_uniforms().

◆ set_uniform_array() [2/4]

template<typename T>
bool cgv::render::shader_program::set_uniform_array ( const context & ctx,
const std::string & name,
const T * array,
size_t nr_elements,
bool generate_error = false )
inline

set uniform array from an array with nr_elements elements of type T pointed to by array

Definition at line 178 of file shader_program.h.

References cgv::render::context::error(), and get_uniform_location().

◆ set_uniform_array() [3/4]

template<typename T>
bool cgv::render::shader_program::set_uniform_array ( const context & ctx,
int loc,
const T & array )
inline

set uniform array from array array where number elements can be derived from array through array_descriptor_traits; supported array types include cgv::math::vec and std::vector

Definition at line 196 of file shader_program.h.

◆ set_uniform_array() [4/4]

template<typename T>
bool cgv::render::shader_program::set_uniform_array ( const context & ctx,
int loc,
const T * array,
size_t nr_elements )
inline

set uniform array from an array with nr_elements elements of type T pointed to by array

Definition at line 201 of file shader_program.h.

◆ set_uniform_block_binding() [1/2]

bool cgv::render::shader_program::set_uniform_block_binding ( const context & ctx,
const std::string & name,
int binding )

Definition at line 727 of file shader_program.cxx.

◆ set_uniform_block_binding() [2/2]

bool cgv::render::shader_program::set_uniform_block_binding ( const context & ctx,
int index,
int binding )

Definition at line 722 of file shader_program.cxx.

◆ update_state()

void cgv::render::shader_program::update_state ( const context & ctx)
protected

ensure that the state has been set in the context

Definition at line 557 of file shader_program.cxx.

References get_max_nr_geometry_shader_output_vertices().

Referenced by enable(), and link().

Member Data Documentation

◆ files_cache

std::map< std::string, std::vector< std::string > > cgv::render::shader_program::files_cache
staticprotected

Definition at line 33 of file shader_program.h.

◆ linked

bool cgv::render::shader_program::linked
protected

Definition at line 36 of file shader_program.h.

◆ nr_attached_geometry_shaders

int cgv::render::shader_program::nr_attached_geometry_shaders
protected

Definition at line 38 of file shader_program.h.

◆ program_file_cache

std::map< std::string, std::string > cgv::render::shader_program::program_file_cache
staticprotected

maps used to cache program file contents and valid file names indexed by their respective file name

Definition at line 32 of file shader_program.h.

Referenced by open_program_file().

◆ show_code_errors

bool cgv::render::shader_program::show_code_errors
protected

Definition at line 35 of file shader_program.h.

◆ state_out_of_date

bool cgv::render::shader_program::state_out_of_date
protected

Definition at line 37 of file shader_program.h.


The documentation for this class was generated from the following files: