Molecular Vis
Improving perception of molecular visualization
Shader Class Reference

Class handling shader construction and managment. More...

#include <Shader.h>

Public Member Functions

 Shader (std::string vertexShader, std::string fragmentShader)
 
 Shader (std::string computeShader)
 
void setUniform (std::string uniform, const glm::vec3 &value)
 
void setUnifrom (GLint location, const glm::vec3 &value)
 
void setUniform (std::string uniform, const glm::uvec3 &value)
 
void setUnifrom (GLint location, const glm::uvec3 &value)
 
void setUniform (std::string uniform, const int value)
 
void setUniform (GLint location, const int value)
 
void setUniform (std::string uniform, const float value)
 
void setUniform (GLint location, const float value)
 
void setUniform (std::string uniform, const glm::mat4 &mat)
 
void setUniform (GLint location, const glm::mat4 &mat)
 
void setUniform (std::string uniform, const glm::mat3 &mat)
 
void setUniform (GLint location, const glm::mat3 &mat)
 
void use ()
 
void unuse ()
 

Static Public Attributes

static const std::string IMPORT_DIRECTIVE = "%%import"
 
static const std::string SHADER_DIRECTORY = "./assets/shader/"
 

Detailed Description

Class handling shader construction and managment.

This class can be used to generate vertex-fragment programs or compute shader programs. It handles the reading of the source files and compilation and linking of the source. It also handles the setting of uniforms and can also handle the import of shaders into other shaders.

Constructor & Destructor Documentation

◆ Shader() [1/2]

Shader::Shader ( std::string  vertexShader,
std::string  fragmentShader 
)

Creates a vertex - fragment shader program

Parameters
vertexShaderfilename of vertex shader, has to be located in SHADER::SHADER_DIRECTORY
fragmentShaderfilename of fragment shader, has to be located in SHADER::SHADER_DIRECTORY

◆ Shader() [2/2]

Shader::Shader ( std::string  computeShader)

Creates a compute shader program

Parameters
computeShaderfilename of compute shader, has to be located in SHADER::SHADER_DIRECTORY

Member Function Documentation

◆ setUniform() [1/10]

void Shader::setUniform ( std::string  uniform,
const glm::vec3 &  value 
)

Set a vec3 uniform

Parameters
uniformstring of uniform name
valueglm::vec3 value to be set

◆ setUniform() [2/10]

void Shader::setUniform ( std::string  uniform,
const glm::uvec3 &  value 
)

Set a uvec3 uniform

Parameters
uniformstring of uniform name
valueglm::uvec3 value to be set

◆ setUniform() [3/10]

void Shader::setUniform ( std::string  uniform,
const int  value 
)

Set a int uniform

Parameters
uniformstring of uniform name
valueint value to be set

◆ setUniform() [4/10]

void Shader::setUniform ( GLint  location,
const int  value 
)

Set a int uniform

Parameters
locationGLint location of uniform
valueint value to be set

◆ setUniform() [5/10]

void Shader::setUniform ( std::string  uniform,
const float  value 
)

Set a float uniform

Parameters
uniformstring of uniform name
valuefloat value to be set

◆ setUniform() [6/10]

void Shader::setUniform ( GLint  location,
const float  value 
)

Set a float uniform

Parameters
locationGLint location of uniform
valuefloat value to be set

◆ setUniform() [7/10]

void Shader::setUniform ( std::string  uniform,
const glm::mat4 &  mat 
)

Set a mat4 uniform

Parameters
uniformstring of uniform name
matglm::mat4 value to be set

◆ setUniform() [8/10]

void Shader::setUniform ( GLint  location,
const glm::mat4 &  mat 
)

Set a mat4 uniform

Parameters
locationGLint location of uniform
matglm::mat4 value to be set

◆ setUniform() [9/10]

void Shader::setUniform ( std::string  uniform,
const glm::mat3 &  mat 
)

Set a uvec3 uniform

Parameters
uniformstring of uniform name
matglm::uvec3 value to be set

◆ setUniform() [10/10]

void Shader::setUniform ( GLint  location,
const glm::mat3 &  mat 
)

Set a mat3 uniform

Parameters
locationGLint location of uniform
matglm::mat3 value to be set

◆ setUnifrom() [1/2]

void Shader::setUnifrom ( GLint  location,
const glm::vec3 &  value 
)

Set a vec3 uniform

Parameters
locationGLint location of uniform
valueglm::vec3 value to be set

◆ setUnifrom() [2/2]

void Shader::setUnifrom ( GLint  location,
const glm::uvec3 &  value 
)

Set a uvec3 uniform

Parameters
locationGLint location of uniform
valueglm::uvec3 value to be set

◆ unuse()

void Shader::unuse ( )

Disables current active shader program.

◆ use()

void Shader::use ( )

Sets the shader program as active.

Member Data Documentation

◆ IMPORT_DIRECTIVE

const std::string Shader::IMPORT_DIRECTIVE = "%%import"
static

Preprocesser directive for import statement. Usage in shader code: <IMPORT_DIRECTIVE> <file>

This directive gets replaced with the code in file before compilation.

◆ SHADER_DIRECTORY

const std::string Shader::SHADER_DIRECTORY = "./assets/shader/"
static

Path to the shader folder


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