DeferredRenderer 1.0
|
Controller for the post process effects in your application. More...
#include <PostProcessor.h>
Public Member Functions | |
PostProcessor () | |
ctor | |
PostProcessor (int _w, int _h, GLuint _vao) | |
arg ctor | |
~PostProcessor () | |
dtor | |
void | init () |
initialize the post processor | |
void | addEffect (const std::string &_effectName, Effect _e) |
add a user effect to the post process chain | |
void | start () |
start the postprocess chain | |
void | finish () |
end the postprocessor | |
void | doEffect (const std::string &_effectName) |
explcict call to invoke effect | |
GLuint | getFinalComposite () |
return the last drawn effect | |
Private Attributes | |
GLuint | m_finalComposite |
the most recently drawn effect | |
ScreenQuad | m_screenQuad |
the full screen quad | |
std::map< std::string, Effect > | m_effects |
the effects chain | |
int | m_width |
fbo w/h | |
int | m_height |
FrameBufferObject | m_fbo |
the post process fbo | |
GLuint | m_vao |
the quad vao | |
int | m_currentAttachment |
the index of the current effect |
Controller for the post process effects in your application.
Definition at line 17 of file PostProcessor.h.
PostProcessor::PostProcessor | ( | ) | [inline] |
PostProcessor::PostProcessor | ( | int | _w, |
int | _h, | ||
GLuint | _vao | ||
) |
arg ctor
[in] | _w | fbo width |
[in] | _h | fbo height |
[in] | _vao | the full screen quad vao |
Definition at line 6 of file PostProcessor.cpp.
References FrameBufferObject::create(), Texture::generateEmpty(), Texture::id, and m_fbo.
: m_screenQuad(0.0f, 0.0f, 0.5f, 1.0f), m_width(_w), m_height(_h), m_fbo(_w,_h), m_vao(_vao), m_currentAttachment(0) { Texture tmp("tmp"); tmp.generateEmpty(_w, _h); m_fbo.create(tmp.id); }
PostProcessor::~PostProcessor | ( | ) | [inline] |
void PostProcessor::addEffect | ( | const std::string & | _effectName, |
Effect | _e | ||
) |
add a user effect to the post process chain
Definition at line 19 of file PostProcessor.cpp.
References m_effects.
{ m_effects.insert(std::pair<std::string, Effect>(_effectName, _e)); }
void PostProcessor::doEffect | ( | const std::string & | _effectName | ) |
explcict call to invoke effect
Definition at line 32 of file PostProcessor.cpp.
References FrameBufferObject::activateTarget(), FrameBufferObject::bindTextureSlot(), ScreenQuad::draw(), m_currentAttachment, m_effects, m_fbo, m_finalComposite, m_screenQuad, and m_vao.
{ m_fbo.bindTextureSlot(m_currentAttachment, m_effects[_effectName].getOutputId()); m_fbo.activateTarget(m_currentAttachment); m_currentAttachment++; if(m_currentAttachment > 3) m_currentAttachment = 0; m_effects[_effectName].prepare(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); m_screenQuad.draw(m_effects[_effectName].getShaderName(), m_vao); m_finalComposite = m_effects[_effectName].getOutputId(); }
void PostProcessor::finish | ( | ) | [inline] |
end the postprocessor
Definition at line 42 of file PostProcessor.h.
References m_fbo, and FrameBufferObject::unbind().
GLuint PostProcessor::getFinalComposite | ( | ) | [inline] |
return the last drawn effect
Definition at line 48 of file PostProcessor.h.
References m_finalComposite.
{return m_finalComposite;}
void PostProcessor::init | ( | ) |
initialize the post processor
void PostProcessor::start | ( | ) |
start the postprocess chain
Definition at line 24 of file PostProcessor.cpp.
References FrameBufferObject::bind(), and m_fbo.
{ m_fbo.bind(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); }
int PostProcessor::m_currentAttachment [private] |
the index of the current effect
Definition at line 71 of file PostProcessor.h.
std::map<std::string, Effect> PostProcessor::m_effects [private] |
the effects chain
Definition at line 59 of file PostProcessor.h.
FrameBufferObject PostProcessor::m_fbo [private] |
the post process fbo
Definition at line 65 of file PostProcessor.h.
GLuint PostProcessor::m_finalComposite [private] |
the most recently drawn effect
Definition at line 53 of file PostProcessor.h.
int PostProcessor::m_height [private] |
Definition at line 62 of file PostProcessor.h.
ScreenQuad PostProcessor::m_screenQuad [private] |
the full screen quad
Definition at line 56 of file PostProcessor.h.
GLuint PostProcessor::m_vao [private] |
the quad vao
Definition at line 68 of file PostProcessor.h.
int PostProcessor::m_width [private] |
fbo w/h
Definition at line 62 of file PostProcessor.h.