IShader Class Reference

Represents a GLSL program object. More...

#include <shader.h>

Inheritance diagram for IShader:

IUniformState CShader

List of all members.

Public Types

enum  shaderType_e { TYPE_VERTEX = 0, TYPE_GEOMETRY = 1, TYPE_FRAGMENT = 2, MAX_SHADER_TYPES = 3 }
 OpenGL independend shader types. More...

Public Member Functions

virtual ~IShader (void)
 Destructor.
virtual bool init (void)=0
 Initialized the object.
virtual void shutdown (void)=0
 Destroys all OpenGL objects and goes back to uninitialized state.
virtual bool bindState (VertexAttribLocations &attribs)=0
 Setups OpenGL to use that program.
virtual bool compileAndLink (void)=0
 Compiles shaders and links the program.
virtual void deactivateProgram (void)=0
 Destroys the current program and makes it unuseable.
virtual QString getBuildLog (void)=0
 Returns a string with compile and link results.
virtual void setShaderSource (int shaderType, const QString &source)=0
 Assigns GLSL source code to a shader.
virtual void setGeometryInputType (int type)=0
 Sets the geometry shaders input primitive type.
virtual void setGeometryOutputType (int type)=0
 Sets the geometry shaders output primitive type.
virtual bool isShaderTypeAvailable (int type)=0
 Check wether a given shader type is avilable for this program.

Static Public Member Functions

static IShadercreate (void)
 Factory for IShader objects.
static QString getShaderTypeName (int type)
 Translates values from shaderType_e into human readable strings.


Detailed Description

Represents a GLSL program object.

Provides methods for compiling and linking GLSL source code to a program object. It supports vertex, fragment and geometry shaders. This interface requires a valid OpenGL 2.0 context to operate. If this object is initialized without such a context, behavior is undefined.


Member Enumeration Documentation

enum IShader::shaderType_e

OpenGL independend shader types.

They can be used as indices into arrays in a for loop.


Member Function Documentation

IShader * IShader::create ( void   )  [static]

Factory for IShader objects.

IShader objects can be created without a valid OpenGL context in use.

Returns:
A new IShader instance.

virtual bool IShader::init ( void   )  [pure virtual]

Initialized the object.

After this call the object is ready to compile and link GLSL code.

Precondition:
Requeires a valid OpenGL context in use.

Implemented in CShader.

virtual bool IShader::bindState ( VertexAttribLocations attribs  )  [pure virtual]

Setups OpenGL to use that program.

If the program was not suceessfully linked, then this call makes OpenGL use the fixed-function pipeline.

Parameters:
attribs Locations of used custom vertex attributes will be returned in this argument. If a vertex attribute is not available, that attribute will be set to -1.
Returns:
True, if the program is in use, False otherwise.

Implemented in CShader.

virtual bool IShader::compileAndLink ( void   )  [pure virtual]

Compiles shaders and links the program.

Is also setups uniform lists and build log. If no sources are specified for all shaders, this call will return true although no program is generated.

Returns:
True if the program was successfully linked. False otherwise.

Implemented in CShader.

virtual void IShader::deactivateProgram ( void   )  [pure virtual]

Destroys the current program and makes it unuseable.

Future calls to bindState() will fail until a call to compileAndLink() successfully created a program.

Implemented in CShader.

virtual QString IShader::getBuildLog ( void   )  [pure virtual]

Returns a string with compile and link results.

This log also includes information about active uniforms and vertex attributes. The log is already formatted, so it can be displayed to the user.

Returns:
The build log string.

Implemented in CShader.

virtual void IShader::setShaderSource ( int  shaderType,
const QString &  source 
) [pure virtual]

Assigns GLSL source code to a shader.

Old source code is replaced with the new code. the program is not changed until compileAndLink() is called. An empty string indicates that the specified shader type should not be attached to the program.

Parameters:
shaderType The shader type to replace.
source The source code.

Implemented in CShader.

virtual void IShader::setGeometryInputType ( int  type  )  [pure virtual]

Sets the geometry shaders input primitive type.

If the program does not support geometry shaders, this call has no effect. If the primitive type is invalid, this call has no effect. This call does not change the porgam. You will have to relink the program for the changes to take effect.

Parameters:
type OpenGL primitive type. Valid types are those specified in the GL_EXT_geometry_shader4 extension.

Implemented in CShader.

virtual void IShader::setGeometryOutputType ( int  type  )  [pure virtual]

Sets the geometry shaders output primitive type.

If the program does not support geometry shaders, this call has no effect. If the primitive type is invalid, this call has no effect. This call does not change the porgam. You will have to relink the program for the changes to take effect.

Parameters:
type OpenGL primitive type. Valid types are those specified in the GL_EXT_geometry_shader4 extension.

Implemented in CShader.

virtual bool IShader::isShaderTypeAvailable ( int  type  )  [pure virtual]

Check wether a given shader type is avilable for this program.

Returns false for invalid input.

Parameters:
type Shader type identifier, defined in shaderType_e
Returns:
Wether the shader type is supported by the program.

Implemented in CShader.

QString IShader::getShaderTypeName ( int  type  )  [static]

Translates values from shaderType_e into human readable strings.

Returns an error string for invalid input.

Parameters:
type Shader type to translate.
Returns:
A human readable shader type name.


The documentation for this class was generated from the following files:
Generated on Sun Mar 2 17:12:32 2008 for Shader Maker by  doxygen 1.5.4