CPPGPGPU Library - Reference (Doxygen)

Main Page | General Use | Reference | Examples Info | Get/Download CPPGPGPU | SF.net Page

Shader Class Reference

Basic element for turning shaders on and off. More...

#include <OGLParts.h>

List of all members.

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.


Detailed Description

Basic element for turning shaders on and off.

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.


Constructor & Destructor Documentation

Shader::Shader (  ) 

Definition at line 45 of file OGLParts.cpp.

Shader::~Shader (  ) 

Definition at line 58 of file OGLParts.cpp.


Member Function Documentation

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  ) 

Activate Shader using default uniform floats.

Definition at line 395 of file OGLParts.cpp.

bool Shader::ActivateShader (  )  [inline]

Activate Shader without any uniforms at all.

Definition at line 90 of file OGLParts.h.

bool Shader::ActivateShader ( const string s  )  [inline]

Activate Shader using exactly one uniform sampler2D.

Definition at line 93 of file OGLParts.h.

bool Shader::DeactivateShader (  ) 

Turn off all shaders.

Definition at line 411 of file OGLParts.cpp.

void Shader::CheckForNewer ( const char *  sShaderName  ) 

Check for newer version of 'this' shader.

Definition at line 63 of file OGLParts.cpp.

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]

Get the last modified time for sShaderName.

Definition at line 74 of file OGLParts.cpp.


Member Data Documentation

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]

The OpenGL Program ID.

Definition at line 113 of file OGLParts.h.

GLhandleARB Shader::geometryShader [private]

The OpenGL Geometry Program ID.

Definition at line 116 of file OGLParts.h.

GLhandleARB Shader::vertexShader [private]

The OpenGL Vertex Program ID.

Definition at line 119 of file OGLParts.h.

GLhandleARB Shader::fragmentShader [private]

The OpenGL Fragment Program ID.

Definition at line 122 of file OGLParts.h.

GLuint Shader::vertexProgram [private]

ASM Only information for vertex programs.

Definition at line 125 of file OGLParts.h.

GLuint Shader::fragmentProgram [private]

ASM Only information for fragment programs.

Definition at line 127 of file OGLParts.h.

bool Shader::bIsGLSLAsm [private]

ASM Only information for programs.

Definition at line 129 of file OGLParts.h.


The documentation for this class was generated from the following files:
© 2005-2007 Charles Lohr, Joshua Allen, David Chapman, Andrew Lohr. All material including documentation under the MIT/X11 license.