UniShader
1.0.0a
Interface for GPGPU and working with shader programs
|
#include <Uniform.h>
Public Types | |
typedef SafePtr< Uniform > | Ptr |
Safe pointer. | |
typedef SafePtr< const Uniform > | PtrConst |
Safe pointer. | |
Public Member Functions | |
Uniform (ShaderProgram &program, std::string name) | |
virtual const std::string & | getClassName () const |
Get name of this class. | |
std::string | getName () const |
Get shader constant name. | |
void | transposeMatrix (bool transpose) |
Transpose matrix. | |
bool | isMatrixTransposed () |
Returns if matrix is transposed. | |
void | getSource () |
TODO. | |
void | clearSource () |
Clear source. | |
void | setSource (float *arr, unsigned int size) |
Set source of data. | |
void | setSource (std::vector< float > vec) |
Set source of data. | |
void | setSource (TextureBuffer::Ptr &textureBuffer) |
Set source of data. | |
const GLSLType & | getGLSLType () const |
Get GLSL type. | |
bool | prepare () |
Prepare uniform. | |
void | apply () |
Apply uniform settings. | |
void | deactivateTextureSource () |
Deactivate active texture source. | |
virtual bool | handleSignal (unsigned int signalID, const ObjectBase *callerPtr) |
Handle incoming signal. |
Uniform class.
Uniforms are constant objects passed to shader program from application. They can be either values, samplers or images and they are uniform throughout whole shader pipeline. This means, for example that uniform with same name in vertex stage and fragment stage must have the same type.
Values (basic variables) are constant values.
Samplers are objects referring to a texture or buffer. Special fetch functions are used to extract data from its data sources.
Images ... aren't supported yet.
NOTE: Uniforms are very complex, therefore only Values and Sampler buffers are currently supported.
void Uniform::apply | ( | ) |
Apply uniform settings.
Modify OpenGL context with settings stored in this class.
void Uniform::clearSource | ( | ) |
Clear source.
Clear any source of data, leaving uniform without source.
void Uniform::deactivateTextureSource | ( | ) |
Deactivate active texture source.
Applying uniform with a texture source activates the texture. This function is used to deactivate it afterwards.
const GLSLType& Uniform::getGLSLType | ( | ) | const |
Get GLSL type.
std::string Uniform::getName | ( | ) | const |
Get shader constant name.
virtual bool Uniform::handleSignal | ( | unsigned int | signalID, |
const ObjectBase * | callerPtr | ||
) | [virtual] |
Handle incoming signal.
signalID | Signal identifier. |
callerPtr | Pointer to object sending signal. |
Implements SignalReceiver.
bool Uniform::isMatrixTransposed | ( | ) |
Returns if matrix is transposed.
bool Uniform::prepare | ( | ) |
Prepare uniform.
Retrieve info about uniform from shader program and prepare uniform for use.
void Uniform::setSource | ( | float * | arr, |
unsigned int | size | ||
) |
Set source of data.
arr | Array with data. |
size | Size of array in elements. |
void Uniform::setSource | ( | std::vector< float > | vec | ) |
Set source of data.
vec | Vector with data. |
void Uniform::setSource | ( | TextureBuffer::Ptr & | textureBuffer | ) |
Set source of data.
textureBuffer | Texture buffer with data. |
void Uniform::transposeMatrix | ( | bool | transpose | ) |
Transpose matrix.
If uniform is matrix type, transposing results in matrix mirrored across main diagonal.
transpose | If true, matrix is transposed. |