UniShader  1.0.0a
Interface for GPGPU and working with shader programs
 All Classes Functions Typedefs Enumerations Enumerator
Public Types | Public Member Functions
Uniform Class Reference

Uniform class. More...

#include <Uniform.h>

Inheritance diagram for Uniform:
SignalReceiver ObjectBase

List of all members.

Public Types

typedef SafePtr< UniformPtr
 Safe pointer.
typedef SafePtr< const UniformPtrConst
 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 GLSLTypegetGLSLType () 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.

Detailed Description

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.


Member Function Documentation

void Uniform::apply ( )

Apply uniform settings.

Modify OpenGL context with settings stored in this class.

Clear source.

Clear any source of data, leaving uniform without source.

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.

Returns:
GLSL type.
std::string Uniform::getName ( ) const

Get shader constant name.

Returns:
Shader constant name.
virtual bool Uniform::handleSignal ( unsigned int  signalID,
const ObjectBase callerPtr 
) [virtual]

Handle incoming signal.

Parameters:
signalIDSignal identifier.
callerPtrPointer to object sending signal.
Returns:
True if handled.

Implements SignalReceiver.

Returns if matrix is transposed.

Returns:
True if matrix is transposed.
bool Uniform::prepare ( )

Prepare uniform.

Retrieve info about uniform from shader program and prepare uniform for use.

Returns:
True if prepared successfully.
void Uniform::setSource ( float *  arr,
unsigned int  size 
)

Set source of data.

Parameters:
arrArray with data.
sizeSize of array in elements.
void Uniform::setSource ( std::vector< float >  vec)

Set source of data.

Parameters:
vecVector with data.
void Uniform::setSource ( TextureBuffer::Ptr textureBuffer)

Set source of data.

Parameters:
textureBufferTexture buffer with data.
void Uniform::transposeMatrix ( bool  transpose)

Transpose matrix.

If uniform is matrix type, transposing results in matrix mirrored across main diagonal.

Parameters:
transposeIf true, matrix is transposed.

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