ShaderProgram Class Reference

Represents a complete shader program. More...

#include "Shader.h"

Collaboration diagram for ShaderProgram:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 ShaderProgram ()
 Constructor.
 ~ShaderProgram ()
 De-constructor.
bool Load (const char *vertexFile, const char *pixelFile)
 Loads a complete shader program.
bool LoadFromMemory (const char *vertexSrc, const char *pixelSrc)
 Loads a complete shader program from memory.
void Attach ()
 Enables the shader program.
void Detach ()
 Disables the shader program.
void SetTexture (GLuint texID, const char *name)
 Attaches a texture to the specified texture attribute.
void SetVector (float x, float y, float z, const char *name)
 Sets a 3D vector shader constant.
void SetFloat (float val, const char *name)
 Sets a single float shader constant.
VertexShaderGetVertexShader ()
PixelShaderGetPixelShader ()

Protected Member Functions

bool CreateShaderProgram ()
 Links the load pixel and vertex shader together.


Detailed Description

Represents a complete shader program.

Definition at line 108 of file Shader.h.


Member Function Documentation

bool ShaderProgram::Load ( const char *  vertexFile,
const char *  pixelFile 
)

Loads a complete shader program.

Parameters:
[in] vertexFile the filename for the vertex shader.
[in] pixelFile the filename for the pixel shader.
Returns:
true on success, false on failure.

Definition at line 151 of file Shader.cpp.

References CreateShaderProgram(), PixelShader::Load(), and VertexShader::Load().

bool ShaderProgram::LoadFromMemory ( const char *  vertexSrc,
const char *  pixelSrc 
)

Loads a complete shader program from memory.

Parameters:
[in] vertexSrc the source for the vertex shader.
[in] pixelSrc the source for the pixel shader.
Returns:
true on success, false on failure.

Definition at line 172 of file Shader.cpp.

References CreateShaderProgram(), PixelShader::LoadFromMemory(), and VertexShader::LoadFromMemory().

void ShaderProgram::SetTexture ( GLuint  texID,
const char *  name 
)

Attaches a texture to the specified texture attribute.

Parameters:
[in] texID the opengl id for the texture.
[in] name the name of the shader attribute.

Definition at line 241 of file Shader.cpp.

void ShaderProgram::SetVector ( float  x,
float  y,
float  z,
const char *  name 
)

Sets a 3D vector shader constant.

Parameters:
[in] x the x value.
[in] y the y value.
[in] z the z value.
[in] name the name of the shader constant.

Definition at line 255 of file Shader.cpp.

Referenced by RTVolumeRenderer::SetLightDiffuseColor(), and RTVolumeRenderer::SetLightDirection().

void ShaderProgram::SetFloat ( float  val,
const char *  name 
)

Sets a single float shader constant.

Parameters:
[in] val the value.
[in] name the name of the shader constant.

Definition at line 269 of file Shader.cpp.

VertexShader& ShaderProgram::GetVertexShader (  )  [inline]

Returns:
a referance to the vertex shader.

Definition at line 180 of file Shader.h.

PixelShader& ShaderProgram::GetPixelShader (  )  [inline]

Returns:
a referance to the pixel shader.

Definition at line 185 of file Shader.h.

bool ShaderProgram::CreateShaderProgram (  )  [protected]

Links the load pixel and vertex shader together.

Returns:
true on success, false on failure.
NOTE: must be called after the vertex and pixel shaders hav been created.

Definition at line 194 of file Shader.cpp.

References ErrorMessage(), PixelShader::GetShaderID(), and VertexShader::GetShaderID().

Referenced by Load(), and LoadFromMemory().


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

Generated on Thu Jan 15 00:58:04 2009 for RTVolumeRendering by  doxygen 1.5.6