class glw::Shader

Overview

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

#include <ShaderProgram.h>

class Shader {
public:
    // typedefs

    typedef std::map<std::string, std::string> ReplaceMap;

    // construction

    Shader(const ShaderType shader_type);
    Shader(const gl::GLenum shader_type);
    ~Shader();

    // methods

    static PShader Create(const ShaderType shader_type);
    static PShader CreateFromFile(const ShaderType shader_type, const std::string& file_name, const ReplaceMap& replace_map = ReplaceMap());
    static PShader CreateFromStr(const ShaderType shader_type, const std::string& shader_code, const ReplaceMap& replace_map = ReplaceMap());
    bool LoadFromStr(const std::string& shader_code, const ReplaceMap& replace_map = ReplaceMap());
    bool LoadFromFile(const std::string& file_name, const ReplaceMap& replace_map = ReplaceMap());
    bool Compile();
    bool IsCompiled() const;
    gl::GLuint GetID() const;
    ShaderType GetType() const;
    std::string GetCompilationLog() const;
};

Detailed Documentation

Maintains the source code strings that defines a shader.

Construction

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.

Methods

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.

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.