UniShader
1.0.0a
Interface for GPGPU and working with shader programs
|
#include <Attribute.h>
Classes | |
class | ReadingMode |
Reading mode. More... | |
class | SignalID |
Signal identifier enum. More... | |
Public Types | |
typedef SafePtr< Attribute > | Ptr |
Safe pointer. | |
typedef SafePtr< const Attribute > | PtrConst |
Safe pointer. | |
Public Member Functions | |
Attribute (ShaderProgram &program, std::string name) | |
virtual const std::string & | getClassName () const |
Get name of this class. | |
void | connectBuffer (BufferBase::Ptr buffer, unsigned int offset=0, unsigned int stride=0) |
Connect buffer to attribute and set it as data source. | |
void | disconnectBuffer () |
Disconnect buffer from attribute. | |
void | normalize (bool norm) |
Normalize integers to range <0; 1> . | |
unsigned int | getBufferOffset () const |
Get buffer offset. | |
unsigned int | getBufferStride () const |
Get buffer stride. | |
const GLSLType & | getGLSLType () const |
Get GLSL type. | |
ReadingMode | getReadingMode () const |
Get reading mode. | |
std::string | getName () const |
Get shader variable name. | |
void | setBufferOffset (unsigned int offset) |
Set buffer offset. | |
void | setBufferStride (unsigned int stride) |
Set buffer stride. | |
void | setReadingMode (ReadingMode readingMode) |
Set reading mode. | |
bool | prepare () |
Prepare attribute. | |
void | apply () |
Apply attribute settings. | |
virtual bool | handleSignal (unsigned int signalID, const ObjectBase *callerPtr) |
Handle incoming signal. |
Attribute class.
Attributes are input variables for GLSL shader programs. In newer GLSL versions attribute keyword was replaced by input keyword, but functionality is the same. Attributes are used for passing data that are different in each shader run.
Data can be stored either in system memory or in buffers in graphics card memory. Using buffers is generally much faster than accessing system memory.
void Attribute::apply | ( | ) |
Apply attribute settings.
Modify OpenGL context with settings stored in this class.
void Attribute::connectBuffer | ( | BufferBase::Ptr | buffer, |
unsigned int | offset = 0 , |
||
unsigned int | stride = 0 |
||
) |
Connect buffer to attribute and set it as data source.
buffer | Buffer. |
offset | Offset of first index. |
stride | Stride between used indices. |
void Attribute::disconnectBuffer | ( | ) |
Disconnect buffer from attribute.
unsigned int Attribute::getBufferOffset | ( | ) | const |
Get buffer offset.
unsigned int Attribute::getBufferStride | ( | ) | const |
Get buffer stride.
const GLSLType& Attribute::getGLSLType | ( | ) | const |
Get GLSL type.
std::string Attribute::getName | ( | ) | const |
Get shader variable name.
ReadingMode Attribute::getReadingMode | ( | ) | const |
Get reading mode.
virtual bool Attribute::handleSignal | ( | unsigned int | signalID, |
const ObjectBase * | callerPtr | ||
) | [virtual] |
Handle incoming signal.
signalID | Signal identifier. |
callerPtr | Pointer to object sending signal. |
Implements SignalReceiver.
void Attribute::normalize | ( | bool | norm | ) |
Normalize integers to range <0; 1> .
Ignored if reading mode isn't integer mode.
norm | Normalize integers. |
bool Attribute::prepare | ( | ) |
Prepare attribute.
Retrieve info about attribute from shader program and prepare attribute for use.
void Attribute::setBufferOffset | ( | unsigned int | offset | ) |
Set buffer offset.
offset | Offset of first index. |
void Attribute::setBufferStride | ( | unsigned int | stride | ) |
Set buffer stride.
stride | Stride between used indices. |
void Attribute::setReadingMode | ( | ReadingMode | readingMode | ) |
Set reading mode.
readingMode | Reading mode. |