#include <shader.h>
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 IShader * | create (void) |
Factory for IShader objects. | |
static QString | getShaderTypeName (int type) |
Translates values from shaderType_e into human readable strings. |
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.
OpenGL independend shader types.
They can be used as indices into arrays in a for loop.
IShader * IShader::create | ( | void | ) | [static] |
virtual bool IShader::init | ( | void | ) | [pure virtual] |
Initialized the object.
After this call the object is ready to compile and link GLSL code.
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.
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. |
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.
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.
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.
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.
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.
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.
type | Shader type identifier, defined in shaderType_e |
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.
type | Shader type to translate. |