#include <GLSLShader.h>
Classes | |
struct | ShaderContents |
A shader is a source code, as such it can be loaded either directly by its source or a filename (containing the source) More... | |
Protected Attributes | |
std::string | header |
std::map< GLint, ShaderContents > | m_hShaderContents |
std::map< GLint, GLhandleARB > | m_hShaders |
GLhandleARB | m_hProgramObject |
This handle stores our program information which encompasses our shader. More... | |
std::shared_ptr< sofa::helper::system::FileEventListener > | m_filelistener |
Public Member Functions | |
GLSLShader () | |
~GLSLShader () | |
void | AddHeader (const std::string &header) |
This builds a header before any shader contents. More... | |
void | AddDefineMacro (const std::string &name, const std::string &value) |
void | SetShaderFileName (GLint target, const std::string &fileName) |
This function loads and returns a text file for our shaders. More... | |
void | SetShaderFromString (GLint target, const std::string &shaderContent) |
void | SetVertexShaderFileName (const std::string &fileName) |
void | SetVertexShaderFromString (const std::string &string) |
void | SetFragmentShaderFileName (const std::string &fileName) |
void | SetFragmentShaderFromString (const std::string &string) |
std::string | GetShaderStageName (GLint target) |
std::string | LoadTextFile (const std::string &strFile) |
This loads our text file for each shader and returns it in a string. More... | |
void | InitShaders () |
This function loads a vertex and fragment shader file. More... | |
void | forceReloadShaderFromFile (const std::string &filename) |
void | InitShaders (const std::string &strVertex, const std::string &strFragment) |
This loads a vertex and fragment shader. More... | |
GLint | GetVariable (std::string strVariable) |
This returns an ID for a variable in our shader. More... | |
GLint | GetAttributeVariable (std::string strVariable) |
This returns an ID for an attribute variable in our shader. More... | |
void | Release () |
This releases our memory for our shader. More... | |
bool | IsReady () const |
GLhandleARB | GetProgram () const |
std::string | GetShaderFileName (GLint type) const |
std::string | GetShaderString (GLint type) const |
std::string | GetHeader () const |
bool | IsSet (GLint type) const |
GLhandleARB | GetShaderID (GLint type) const |
std::string | GetVertexShaderFileName () const |
GLhandleARB | GetVertexShaderID () const |
std::string | GetFragmentShaderFileName () const |
GLhandleARB | GetFragmentShaderID () const |
void | SetInt (GLint variable, int newValue) |
void | SetFloat (GLint variable, float newValue) |
void | SetInt2 (GLint variable, int i1, int i2) |
void | SetInt3 (GLint variable, int i1, int i2, int i3) |
void | SetInt4 (GLint variable, int i1, int i2, int i3, int i4) |
void | SetFloat2 (GLint variable, float v0, float v1) |
void | SetFloat3 (GLint variable, float v0, float v1, float v2) |
void | SetFloat4 (GLint variable, float v0, float v1, float v2, float v3) |
void | SetIntVector (GLint variable, GLsizei count, const GLint *value) |
void | SetIntVector2 (GLint variable, GLsizei count, const GLint *value) |
void | SetIntVector3 (GLint variable, GLsizei count, const GLint *value) |
void | SetIntVector4 (GLint variable, GLsizei count, const GLint *value) |
void | SetFloatVector (GLint variable, GLsizei count, const float *value) |
void | SetFloatVector2 (GLint variable, GLsizei count, const float *value) |
void | SetFloatVector3 (GLint variable, GLsizei count, const float *value) |
void | SetFloatVector4 (GLint variable, GLsizei count, const float *value) |
void | SetMatrix2 (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
void | SetMatrix3 (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
void | SetMatrix4 (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) |
void | SetMatrix2x3 (GLint, GLsizei, GLboolean, const GLfloat *) |
void | SetMatrix3x2 (GLint, GLsizei, GLboolean, const GLfloat *) |
void | SetMatrix2x4 (GLint, GLsizei, GLboolean, const GLfloat *) |
void | SetMatrix4x2 (GLint, GLsizei, GLboolean, const GLfloat *) |
void | SetMatrix3x4 (GLint, GLsizei, GLboolean, const GLfloat *) |
void | SetMatrix4x3 (GLint, GLsizei, GLboolean, const GLfloat *) |
void | TurnOn () |
void | TurnOff () |
Static Public Member Functions | |
static bool | InitGLSL () |
This is used to load all of the extensions and checks compatibility. More... | |
static GLhandleARB | GetActiveShaderProgram () |
static void | SetActiveShaderProgram (GLhandleARB s) |
Protected Member Functions | |
bool | CompileShader (GLint target, const ShaderContents &shaderContent, const std::string &header) |
This function compiles a shader and check the log. More... | |
|
protected |
|
protected |
|
protected |
This handle stores our program information which encompasses our shader.
|
protected |
|
protected |
sofa::gl::GLSLShader::GLSLShader | ( | ) |
sofa::gl::GLSLShader::~GLSLShader | ( | ) |
void sofa::gl::GLSLShader::AddDefineMacro | ( | const std::string & | name, |
const std::string & | value | ||
) |
void sofa::gl::GLSLShader::AddHeader | ( | const std::string & | header | ) |
This builds a header before any shader contents.
|
protected |
This function compiles a shader and check the log.
void sofa::gl::GLSLShader::forceReloadShaderFromFile | ( | const std::string & | filename | ) |
|
static |
GLint sofa::gl::GLSLShader::GetAttributeVariable | ( | std::string | strVariable | ) |
This returns an ID for an attribute variable in our shader.
|
inline |
|
inline |
std::string sofa::gl::GLSLShader::GetHeader | ( | ) | const |
|
inline |
std::string sofa::gl::GLSLShader::GetShaderFileName | ( | GLint | type | ) | const |
GLhandleARB sofa::gl::GLSLShader::GetShaderID | ( | GLint | type | ) | const |
std::string sofa::gl::GLSLShader::GetShaderStageName | ( | GLint | target | ) |
std::string sofa::gl::GLSLShader::GetShaderString | ( | GLint | type | ) | const |
GLint sofa::gl::GLSLShader::GetVariable | ( | std::string | strVariable | ) |
This returns an ID for a variable in our shader.
This function returns a variable ID for a shader variable.
|
inline |
|
inline |
|
static |
This is used to load all of the extensions and checks compatibility.
void sofa::gl::GLSLShader::InitShaders | ( | ) |
This function loads a vertex and fragment shader file.
|
inline |
This loads a vertex and fragment shader.
|
inline |
These are our basic get functions for our private data
bool sofa::gl::GLSLShader::IsSet | ( | GLint | type | ) | const |
std::string sofa::gl::GLSLShader::LoadTextFile | ( | const std::string & | strFile | ) |
This loads our text file for each shader and returns it in a string.
This function loads and returns a text file for our shaders.
void sofa::gl::GLSLShader::Release | ( | ) |
This releases our memory for our shader.
This function frees all of our shader data.
|
static |
void sofa::gl::GLSLShader::SetFloat | ( | GLint | variable, |
float | newValue | ||
) |
void sofa::gl::GLSLShader::SetFloatVector | ( | GLint | variable, |
GLsizei | count, | ||
const float * | value | ||
) |
void sofa::gl::GLSLShader::SetFloatVector2 | ( | GLint | variable, |
GLsizei | count, | ||
const float * | value | ||
) |
void sofa::gl::GLSLShader::SetFloatVector3 | ( | GLint | variable, |
GLsizei | count, | ||
const float * | value | ||
) |
void sofa::gl::GLSLShader::SetFloatVector4 | ( | GLint | variable, |
GLsizei | count, | ||
const float * | value | ||
) |
|
inline |
|
inline |
void sofa::gl::GLSLShader::SetInt | ( | GLint | variable, |
int | newValue | ||
) |
Below are functions to set an integer or a float
void sofa::gl::GLSLShader::SetInt2 | ( | GLint | variable, |
int | i1, | ||
int | i2 | ||
) |
Below are functions to set more than 1 integer or float
void sofa::gl::GLSLShader::SetInt3 | ( | GLint | variable, |
int | i1, | ||
int | i2, | ||
int | i3 | ||
) |
void sofa::gl::GLSLShader::SetInt4 | ( | GLint | variable, |
int | i1, | ||
int | i2, | ||
int | i3, | ||
int | i4 | ||
) |
void sofa::gl::GLSLShader::SetIntVector | ( | GLint | variable, |
GLsizei | count, | ||
const GLint * | value | ||
) |
Below are functions to set a vector of integer or float
void sofa::gl::GLSLShader::SetIntVector2 | ( | GLint | variable, |
GLsizei | count, | ||
const GLint * | value | ||
) |
void sofa::gl::GLSLShader::SetIntVector3 | ( | GLint | variable, |
GLsizei | count, | ||
const GLint * | value | ||
) |
void sofa::gl::GLSLShader::SetIntVector4 | ( | GLint | variable, |
GLsizei | count, | ||
const GLint * | value | ||
) |
void sofa::gl::GLSLShader::SetMatrix2 | ( | GLint | location, |
GLsizei | count, | ||
GLboolean | transpose, | ||
const GLfloat * | value | ||
) |
Below are functions to set a matrix
|
inline |
|
inline |
void sofa::gl::GLSLShader::SetMatrix3 | ( | GLint | location, |
GLsizei | count, | ||
GLboolean | transpose, | ||
const GLfloat * | value | ||
) |
|
inline |
|
inline |
void sofa::gl::GLSLShader::SetMatrix4 | ( | GLint | location, |
GLsizei | count, | ||
GLboolean | transpose, | ||
const GLfloat * | value | ||
) |
|
inline |
|
inline |
void sofa::gl::GLSLShader::SetShaderFileName | ( | GLint | target, |
const std::string & | fileName | ||
) |
This function loads and returns a text file for our shaders.
void sofa::gl::GLSLShader::SetShaderFromString | ( | GLint | target, |
const std::string & | shaderContent | ||
) |
|
inline |
|
inline |
void sofa::gl::GLSLShader::TurnOff | ( | ) |
void sofa::gl::GLSLShader::TurnOn | ( | ) |
These 2 functions turn on and off our shader