| 
    cgv
    
   | 
 
#include <shader_code.h>
  
Public Member Functions | |
| shader_code () | |
| create shader a shader code object  | |
| ~shader_code () | |
| calls the destruct method  | |
| void | destruct (const context &ctx) | 
| destruct shader code  More... | |
| bool | read_code (const context &ctx, const std::string &file_name, ShaderType st=ST_DETECT, std::string defines="") | 
| read shader code from file  More... | |
| bool | set_code (const context &ctx, const std::string &source, ShaderType st) | 
| set shader code from string  | |
| void | set_defines (std::string &source, const std::string &defines) | 
| set shader code defines  | |
| ShaderType | get_shader_type () const | 
| return the shader type of this code  | |
| bool | compile (const context &ctx) | 
| compile attached source; returns true if successful  | |
| bool | read_and_compile (const context &ctx, const std::string &file_name, ShaderType st=ST_DETECT, bool show_error=true, std::string defines="") | 
| read shader code from file, compile and print error message if necessary  More... | |
| bool | is_compiled () const | 
| return whether shader has been compiled successfully  | |
| virtual bool | is_created () const | 
| return whether component has been created  | |
| void | put_id_void (void *ptr) const | 
| 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 std::string | find_file (const std::string &file_name) | 
| static std::string | get_last_error (const std::string &file_name, const std::string &last_error) | 
| static std::string | read_code_file (const std::string &file_name, std::string *_last_error=0) | 
| read shader code from file and return string with content or empty string if read failed  | |
| static ShaderType | detect_shader_type (const std::string &file_name) | 
Public Attributes | |
| const context * | ctx_ptr | 
| keep pointer to my context  | |
| std::string | last_error | 
| a string that contains the last error  | |
Protected Attributes | |
| ShaderType | st | 
| store the shader type  | |
a shader code object holds a code fragment of a geometry vertex or fragment shader and can be added to a shader program.
| void cgv::render::shader_code::destruct | ( | const context & | ctx | ) | 
destruct shader code
destruct shader
      
  | 
  static | 
detect the shader type from the extension of the given file_name, i.e. 
      
  | 
  static | 
Check if file exists. If not, check if a resource file of this file_name has been registered. If not search it recursively in the shader_path of the shader_config that can be accessed with the function get_shader_config(). This path is initialized to the environment variable CGV_SHADER_PATH or empty if that is not defined.
      
  | 
  static | 
format given last error in a way that developer environments can locate errors in the source file
query the last error in a way that developer environments can locate errors in the source file
      
  | 
  inherited | 
copy the rendering api specific id the component to the memory location of the given pointer. For opengl this the passed pointer should be of type GLint or GLuint.
| bool cgv::render::shader_code::read_and_compile | ( | const context & | ctx, | 
| const std::string & | file_name, | ||
| ShaderType | st = ST_DETECT,  | 
        ||
| bool | show_error = true,  | 
        ||
| std::string | defines = ""  | 
        ||
| ) | 
read shader code from file, compile and print error message if necessary
read shader code with read_code and compile. If show_error is true print error messages formated with the get_last_error method in case an error arose.
| bool cgv::render::shader_code::read_code | ( | const context & | ctx, | 
| const std::string & | file_name, | ||
| ShaderType | st = ST_DETECT,  | 
        ||
| std::string | defines = ""  | 
        ||
| ) | 
read shader code from file
read shader code from file that is searched for with find_file. If the shader type defaults to ST_DETECT, the detect_shader_type() method is applied to the file name.