DeferredRenderer 1.0

Effect Class Reference

Encapsulation of what an effect represents within this context effects have a shader, an output and several sources. More...

#include <Effect.h>

List of all members.

Public Member Functions

 Effect ()
 ctor
 Effect (GLuint _texId, const std::string &_shaderName)
 argument ctor
 ~Effect ()
 dtor
void addSourceTexture (const std::string &_samplerName, GLuint _texId)
 add a source texture to samples from
void prepare ()
 setup this effect for use, enabling texture 2d and shader
GLuint getOutputId ()
 access the texture id of this effects output
std::string getShaderName ()

Private Attributes

std::vector< GLuint > m_sources
 the texture handles of the effects sources
GLuint m_output
 the texture handle of the output
std::string m_shaderName
 the effects shadername

Detailed Description

Encapsulation of what an effect represents within this context effects have a shader, an output and several sources.

Definition at line 16 of file Effect.h.


Constructor & Destructor Documentation

Effect::Effect ( ) [inline]

ctor

Definition at line 19 of file Effect.h.

{}
Effect::Effect ( GLuint  _texId,
const std::string &  _shaderName 
)

argument ctor

Parameters:
[in]_texIdthe output texture id
[in]_shaderNamethe name of the ngl::shader used for this effect

Definition at line 6 of file Effect.cpp.

                                                         :m_output(_texId),m_shaderName(_shaderName)
{
}
Effect::~Effect ( )

dtor

Definition at line 10 of file Effect.cpp.

{}

Member Function Documentation

void Effect::addSourceTexture ( const std::string &  _samplerName,
GLuint  _texId 
)

add a source texture to samples from

Parameters:
[in]_samplerNamethe name of the uniform sampler in the fragment shader for this source
[in]_texIdthe source texture id

Definition at line 12 of file Effect.cpp.

References m_shaderName, and m_sources.

{
    ngl::ShaderManager *shader = ngl::ShaderManager::instance();
    (*shader)[m_shaderName]->use();
    shader->setShaderParam1i(m_shaderName,_samplerName,m_sources.size());

    m_sources.push_back(_texId);
}

Here is the caller graph for this function:

GLuint Effect::getOutputId ( ) [inline]

access the texture id of this effects output

Returns:
GLuint texture id of finished effect

Definition at line 37 of file Effect.h.

References m_output.

{return m_output;}
std::string Effect::getShaderName ( ) [inline]
Returns:
string the shader name

Definition at line 41 of file Effect.h.

References m_shaderName.

{return m_shaderName;}
void Effect::prepare ( )

setup this effect for use, enabling texture 2d and shader

Definition at line 21 of file Effect.cpp.

References m_shaderName, and m_sources.

{
    ngl::ShaderManager *shader = ngl::ShaderManager::instance();
    (*shader)[m_shaderName]->use();

    for(unsigned int i = 0; i < m_sources.size(); i++)
    {
        glActiveTexture(GL_TEXTURE0 + i);
        glBindTexture(GL_TEXTURE_2D, m_sources[i]);
    }
}

Member Data Documentation

GLuint Effect::m_output [private]

the texture handle of the output

Definition at line 47 of file Effect.h.

std::string Effect::m_shaderName [private]

the effects shadername

Definition at line 49 of file Effect.h.

std::vector<GLuint> Effect::m_sources [private]

the texture handles of the effects sources

Definition at line 45 of file Effect.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Defines