GLW
Computer Graphics Structures library
glw::Shader Class Reference

Maintains the source code strings that defines a shader. More...

Public Types

using ReplaceMap = std::map< std::string, std::string >
 

Public Member Functions

 Shader (const ShaderType shader_type)
 Create new shader object of specified type.
 
 Shader (const gl::GLenum shader_type)
 Create new shader object of specified type.
 
 ~Shader ()
 Destroy shader object and release OpenGL resources.
 
bool LoadFromStr (const std::string &shader_code, const ReplaceMap &replace_map=ReplaceMap())
 Load shader source from string.
 
bool LoadFromFile (const std::string &file_name, const ReplaceMap &replace_map=ReplaceMap())
 Load shader source from text file.
 
bool Compile ()
 Compiles shader and returns whether was compilation successful.
 
bool IsCompiled () const
 Checks, if last compilation was successful.
 
gl::GLuint GetID () const
 Returns OpenGL reference id.
 
ShaderType GetType () const
 Get type of this.
 
std::string GetCompilationLog () const
 Get log of last compilation with errors and warnings. If no errors, function returns empty string.
 

Static Public Member Functions

static PShader Create (const ShaderType shader_type)
 Crate a shader object and return reference.
 
static PShader CreateFromFile (const ShaderType shader_type, const std::string &file_name, const ReplaceMap &replace_map=ReplaceMap())
 Create and compile a shader object and show compilation errors.
 
static PShader CreateFromStr (const ShaderType shader_type, const std::string &shader_code, const ReplaceMap &replace_map=ReplaceMap())
 Create and compile a shader object and show compilation errors.
 

Detailed Description

Maintains the source code strings that defines a shader.