Tucano  0.1
A library for rapid prototyping with modern OpenGL and GLSL
Tucano::Effect Class Referenceabstract

The Effect class is a holder for Shaders. It is completely optional, but is contains a few methods for convenience, and is extremely useful to organize shaders belonging to a single effect (such as multipass strategies). More...

#include <effect.hpp>

Inheritance diagram for Tucano::Effect:
Tucano::Effects::BlurredNormalMap Tucano::Effects::CameraBuffer Tucano::Effects::DirectColor Tucano::Effects::GradientFilter Tucano::Effects::MeanFilter Tucano::Effects::NormalMap Tucano::Effects::OrenNayar Tucano::Effects::Phong Tucano::Effects::PhongShadowmap Tucano::Effects::Picking Tucano::Effects::RenderBuffer Tucano::Effects::RenderTexture Tucano::Effects::ShadowMap Tucano::Effects::SSAO Tucano::Effects::Toon Tucano::Effects::Wireframe

Public Member Functions

 Effect (string shadersDir="shaders/")
 Default constructor. More...
 
virtual void initialize (void)=0
 Initializes all effect's funcionality. More...
 
virtual ShaderloadShader (string shader_name)
 Loads a shader by filename, initializes it, and inserts in shaders list. More...
 
virtual void loadShader (Shader &shader, string shader_name)
 
virtual ShaderloadShader (string shader_name, string vertex_name, string frag_name, string geom_name)
 Loads a shader by complete filenames (with extensions), initializes it, and inserts in shaders list. More...
 
void setShadersDir (string dir)
 
virtual void reloadShaders (void)
 Reloads all shaders needed for effect usage. More...
 

Protected Attributes

std::vector< Shader * > shaders_list
 Vector of pointers to shaders used in this effect, in case the user needs multiple pass rendering. More...
 
string shaders_dir
 Directory in which the shader files are stored. More...
 

Detailed Description

The Effect class is a holder for Shaders. It is completely optional, but is contains a few methods for convenience, and is extremely useful to organize shaders belonging to a single effect (such as multipass strategies).

This class should be extended in order to hold a full GLSL effect, it does not necessarily needs to be a render effect, but any GPU application. By loading the Shaders trough the loadShader method, the effect class also mantains the list of Shaders and can reload all shaders with a single call.

Constructor & Destructor Documentation

Tucano::Effect::Effect ( string  shadersDir = "shaders/")
inline

Default constructor.

Parameters
shadersDirThe directory containing the shader files.

Member Function Documentation

virtual void Tucano::Effect::initialize ( void  )
pure virtual

Initializes all effect's funcionality.

This method must be implemented in the extended class. It will typically hold the shader loading, however, if the application uses other parameters, their initialization can also be done in this method.

Implemented in Tucano::Effects::SSAO, Tucano::Effects::CameraBuffer, Tucano::Effects::ShadowMap, Tucano::Effects::Toon, Tucano::Effects::Phong, Tucano::Effects::Wireframe, Tucano::Effects::GradientFilter, Tucano::Effects::DirectColor, Tucano::Effects::OrenNayar, Tucano::Effects::RenderBuffer, Tucano::Effects::RenderTexture, Tucano::Effects::NormalMap, Tucano::Effects::PhongShadowmap, Tucano::Effects::MeanFilter, Tucano::Effects::BlurredNormalMap, and Tucano::Effects::Picking.

virtual Shader* Tucano::Effect::loadShader ( string  shader_name)
inlinevirtual

Loads a shader by filename, initializes it, and inserts in shaders list.

The name should be passed without extensions, the method will automatically search the shader directory for shader extensions (vert, frag, geom, comp).

Parameters
shader_nameString with filename without extensions.
virtual void Tucano::Effect::loadShader ( Shader shader,
string  shader_name 
)
inlinevirtual
virtual Shader* Tucano::Effect::loadShader ( string  shader_name,
string  vertex_name,
string  frag_name,
string  geom_name 
)
inlinevirtual

Loads a shader by complete filenames (with extensions), initializes it, and inserts in shaders list.

Parameters
shader_nameString with name of the shader
vertex_nameVertex shader filename
frag_nameFragment shader filename
geom_nameGeometry shader filename
virtual void Tucano::Effect::reloadShaders ( void  )
inlinevirtual

Reloads all shaders needed for effect usage.

This method allows the user to change the shaders codes and see the results in real time, sparing him the need to restart the application.

void Tucano::Effect::setShadersDir ( string  dir)
inline

Sets the shaders files directory.

Todo:
include slash at the end if missing
Parameters
dirThe directory containing the Shader files.

Member Data Documentation

string Tucano::Effect::shaders_dir
protected

Directory in which the shader files are stored.

std::vector< Shader* > Tucano::Effect::shaders_list
protected

Vector of pointers to shaders used in this effect, in case the user needs multiple pass rendering.


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