# Shader Class Reference

`#include <Shader.h>`

Collaboration diagram for Shader:
[legend]

List of all members.

## Public Member Functions
| Shader (void)
virtual | ~Shader (void)
bool | loadShader (string vertexShaderFile, string fragmentShaderFile)
bool | isInitialized ()
void | use ()
void | passUniformSampler3D (const string &variableName, const Texture3D *tex3D)
void | passUniformSampler1D (const string &variableName, const Texture1D *tex3D)
## Static Public Member Functions
static void | dropCurrentShader ()
## Private Member Functions
const char * | readTextFile (string filename)
## Static Private Member Functions
static void | releaseActiveTextureUnits ()
## Private Attributes
GLenum | m_shaderProgram
GLenum | m_vertexShader
GLenum | m_fragmentShader
bool | m_initialized
## Static Private Attributes
static Shader * | m_activeShader = NULL
static int | m_textureUnitTargets [64] = {0}
static int | m_activeTextureUnit = 0

## Constructor & Destructor Documentation

Shader::Shader | ( | void |  | ) |

Shader::~Shader | ( | void |  | ) | `[virtual]`

## Member Function Documentation

void Shader::dropCurrentShader | ( |  | ) | `[static]`

Deactivates the current used shader program. Internally calls glUseProgramObjectARB(0) and releases all active texture units

bool Shader::isInitialized | ( |  | ) |

Returns:
  true, if this Shader object is initialized by some shader program

bool Shader::loadShader | ( | string | vertexShaderFile,
|  | string | fragmentShaderFile |
| ) |  |  |

Loads a Shader program from the given vertesShader- and fragmentShader-File. TODO: extended error handling and and report if shader files have syntax errors and so on

void Shader::passUniformSampler1D | ( | const string & | variableName,
|  | const Texture1D * | tex3D |
| ) |  |  |

void Shader::passUniformSampler3D | ( | const string & | variableName,
|  | const Texture3D * | tex3D |
| ) |  |  |

Resets the internal activeTextureunit-Counter to zero. Call this function before each sequence of passUniformSampler3D()-call.

void Shader::beginPassTextures() { Disable all prviously used targets in the Active Texture Units Shader::releaseActiveTextureUnits();

use();

m_activeTextureUnit = 0; }

const char * Shader::readTextFile | ( | string | filename | ) | `[private]`

Reads a textfile from the harddrive, and returns as const char* buffer. Used for shader source loading Remarks: The const char* buffer allocated in this method is to be released by a delete[] call later

Parameters:

  | filename | the path to the textfile to load

Returns:
  a pointer to the buffer containing the file content

void Shader::releaseActiveTextureUnits | ( |  | ) | `[static, private]`

Disables all targets of the active Shader previously enabled in Active Texture Units and sets it internal activeTextureUnit counter to 0

void Shader::use | ( |  | ) |

Uses this Shader's program in the following shading operations

## Member Data Documentation

Shader * Shader::m_activeShader = NULL`[static, private]`

int Shader::m_activeTextureUnit = 0`[static, private]`

GLenum Shader::m_fragmentShader`[private]`

bool Shader::m_initialized`[private]`

GLenum Shader::m_shaderProgram`[private]`

int Shader::m_textureUnitTargets = {0}`[static, private]`

GLenum Shader::m_vertexShader`[private]`

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

- F:/Meine Dateien/Visual Studio 2005/Projects/InsightFlow/header/Shader.h
- F:/Meine Dateien/Visual Studio 2005/Projects/InsightFlow/src/Shader.cpp