#include <OGLParts.h>
Public Member Functions | |
Shader () | |
~Shader () | |
bool | LoadShader (const char *sShaderName) |
Suggested function for loading shaders. | |
bool | LoadShaderFrag (const char *sShaderCode) |
Explicitly load a fragment shader. | |
bool | LoadShaderVert (const char *sShaderCode) |
Explicitly load a vertex shader. | |
bool | LoadShaderGeom (const char *sShaderCode) |
Explicitly load a geometry shader. | |
bool | LinkShaders () |
Explicitly link all shaders currently loaded. | |
bool | ActivateShader (vector< string > &vsAllSamplerLocs, vector< string > &vsUniformFloats, vector< float > &vfUniformFloats) |
Activate shader with extra parameters. | |
bool | ActivateShader (vector< string > &vsAllSamplerLocs) |
Activate Shader using default uniform floats. | |
bool | ActivateShader () |
Activate Shader without any uniforms at all. | |
bool | ActivateShader (const string &s) |
Activate Shader using exactly one uniform sampler2D. | |
bool | DeactivateShader () |
Turn off all shaders. | |
void | CheckForNewer (const char *sShaderName) |
Check for newer version of 'this' shader. | |
GLhandleARB | GetProgramID () |
Explicitly get the OpenGL ProgramID in the event you need it for advanced techniques. | |
Private Member Functions | |
void | GetTimeCodes (unsigned long *iOut, const char *sShaderName) |
Get the last modified time for sShaderName. | |
Private Attributes | |
unsigned long | iTimeCode [3] |
The last time codes (for vertex and fragment shaders respectively). | |
GLhandleARB | iProgramID |
The OpenGL Program ID. | |
GLhandleARB | geometryShader |
The OpenGL Geometry Program ID. | |
GLhandleARB | vertexShader |
The OpenGL Vertex Program ID. | |
GLhandleARB | fragmentShader |
The OpenGL Fragment Program ID. | |
GLuint | vertexProgram |
ASM Only information for vertex programs. | |
GLuint | fragmentProgram |
ASM Only information for fragment programs. | |
bool | bIsGLSLAsm |
ASM Only information for programs. |
This class helps aide in the loading and use of shaders. It allows loading of files through the LoadShader() function that actively looks for .frag and .vert files. By use of the CheckForNewer() function, the class looks for changes, if any changes are found the shaders will be re-loaded, compiled and linked. Once this node has a shader loaded, the shader can be activated or deactivated using the ActivateShader() and DeactivateShader() functions respectively. Note that shaders do not stack. When you call DeactiveShader(), it does not bring back previously activated shaders. It simply turns all shaders off.
Definition at line 43 of file OGLParts.h.
Shader::Shader | ( | ) |
Definition at line 45 of file OGLParts.cpp.
Shader::~Shader | ( | ) |
Definition at line 58 of file OGLParts.cpp.
bool Shader::LoadShader | ( | const char * | sShaderName | ) |
Suggested function for loading shaders.
This function looks for {sShaderName}.vert and {sShaderName}.frag. It will attempt to load, compile and link the files. If any errors are found, they will be announced at STDOUT. When Geometry shader support is added, it will search for .geom files
Definition at line 85 of file OGLParts.cpp.
bool Shader::LoadShaderFrag | ( | const char * | sShaderCode | ) |
Explicitly load a fragment shader.
This function takes on raw code in the sShaderCode string and attemps to compile it. Any errors it runs into will be displayed at STDOUT. Note you are discouraged to use this function, in favor of using LoadShader().
Definition at line 172 of file OGLParts.cpp.
bool Shader::LoadShaderVert | ( | const char * | sShaderCode | ) |
Explicitly load a vertex shader.
This function takes on raw code in the sShaderCode string and attemps to compile it. Any errors it runs into will be displayed at STDOUT. You should use LoadShader() instead of this function.
Definition at line 213 of file OGLParts.cpp.
bool Shader::LoadShaderGeom | ( | const char * | sShaderCode | ) |
Explicitly load a geometry shader.
This function takes on raw code in the sShaderCode string and attemps to compile it. Any errors it runs into will be displayed at STDOUT. You should use LoadShader() instead of this function.
Definition at line 257 of file OGLParts.cpp.
bool Shader::LinkShaders | ( | ) |
Explicitly link all shaders currently loaded.
This takes vertexShader and fragmentShader and converts them into iProgramID. this function is discouraged when using LoadShader().
Definition at line 293 of file OGLParts.cpp.
bool Shader::ActivateShader | ( | vector< string > & | vsAllSamplerLocs, | |
vector< string > & | vsUniformFloats, | |||
vector< float > & | vfUniformFloats | |||
) |
Activate shader with extra parameters.
Activate 'this' shader with the following uniform sampler2D values in vsAllSamplerLocs, this assigns numerically values 0-8 to the values in vsAllSamplerLocs. vsUniformFloats are uniform floats that get assigned values vfUniformFloats. Then it turns the shader on for all future rendering
Definition at line 357 of file OGLParts.cpp.
bool Shader::ActivateShader | ( | vector< string > & | vsAllSamplerLocs | ) |
bool Shader::ActivateShader | ( | ) | [inline] |
bool Shader::ActivateShader | ( | const string & | s | ) | [inline] |
bool Shader::DeactivateShader | ( | ) |
void Shader::CheckForNewer | ( | const char * | sShaderName | ) |
GLhandleARB Shader::GetProgramID | ( | ) | [inline] |
Explicitly get the OpenGL ProgramID in the event you need it for advanced techniques.
Definition at line 102 of file OGLParts.h.
void Shader::GetTimeCodes | ( | unsigned long * | iOut, | |
const char * | sShaderName | |||
) | [private] |
unsigned long Shader::iTimeCode[3] [private] |
The last time codes (for vertex and fragment shaders respectively).
Definition at line 110 of file OGLParts.h.
GLhandleARB Shader::iProgramID [private] |
GLhandleARB Shader::geometryShader [private] |
GLhandleARB Shader::vertexShader [private] |
GLhandleARB Shader::fragmentShader [private] |
GLuint Shader::vertexProgram [private] |
GLuint Shader::fragmentProgram [private] |
bool Shader::bIsGLSLAsm [private] |