SPIN Framework
Public Member Functions | Protected Attributes

spin::Shader Class Reference

A wrapper for GLSL shaders. More...

#include <Shader.h>

Inheritance diagram for spin::Shader:
spin::ReferencedStateSet spin::ImageTexture spin::SharedVideoTexture spin::SyphonTexture spin::VideoTexture

List of all members.

Public Member Functions

 Shader (SceneManager *sceneManager, const char *initID)
virtual void updateCallback ()
virtual void debug ()
void printShaderSource ()
void clearUniforms ()
void registerUniform (const char *name, const char *type)
void registerUniform (const char *name, const char *type, const char *defaultValue)
bool loadJitterShader (std::string path)
void loadGLSLShader (std::string path)
void setUniform_bool (const char *name, int b)
void setUniform_int (const char *name, int b)
void setUniform_float (const char *name, float f)
void setUniform_vec2 (const char *name, float x, float y)
void setUniform_vec3 (const char *name, float x, float y, float z)
void setUniform_vec4 (const char *name, float x, float y, float z, float w)
void setShader (const char *path)
const char * getShader () const
virtual std::vector< lo_message > getState () const

Protected Attributes

osg::ref_ptr< osg::Program > programObject_
osg::ref_ptr< osg::Shader > vertexObject_
osg::ref_ptr< osg::Shader > fragmentObject_
std::string shaderPath_
float updateRate_
osg::Timer_t lastTick_

Detailed Description

A wrapper for GLSL shaders.


Member Function Documentation

void spin::Shader::clearUniforms ( )

Remove all uniforms from this stateset

void spin::Shader::debug ( ) [virtual]

Print debug information to console.

Reimplemented from spin::ReferencedStateSet.

Reimplemented in spin::ImageTexture, spin::SharedVideoTexture, spin::SyphonTexture, and spin::VideoTexture.

std::vector< lo_message > spin::Shader::getState ( ) const [virtual]

Just like a ReferencedNode, each subclass of ReferencedStateSet must override the getState() method to pass it's current state.

Reimplemented from spin::ReferencedStateSet.

Reimplemented in spin::ImageTexture, spin::SharedVideoTexture, spin::SyphonTexture, and spin::VideoTexture.

void spin::Shader::registerUniform ( const char *  name,
const char *  type 
)

Create a uniform with the provided name and type. The value will be set to some default value

void spin::Shader::registerUniform ( const char *  name,
const char *  type,
const char *  defaultValue 
)

Create a uniform with the provided name and type, and set the initial value for the uniform.

Note that defaults are provided as strings in all cases. So in the case of several values, the defaultValue would be a space-separated list of values.

It is also possible to specify an array of vectors. For example, if the type is vec2, you can specify a defaultValue of 0.0 0.1 1.0 1.0 and this will generate two vec2 uniforms with indexes automatically added to the name: uniform name[0] = vec2(0.0,0.1); uniform name[1] = vec2(1.0,1.0); To send OSC messages to control these uniforms, you need to use the full name including square brackets. For example: /SPIN/default/shader setUniform_vec2 name[0] 0.0 0.0

void spin::Shader::setShader ( const char *  path)

Creates a texture from a path on disk.

void spin::Shader::updateCallback ( ) [virtual]

This callback occurs every frame to update the state with any parameter changes.

Reimplemented from spin::ReferencedStateSet.


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