TheCherno / Sparky

Cross-Platform High Performance 2D/3D game engine for people like me who like to write code.
Apache License 2.0
1.1k stars 223 forks source link

Multiple post effects passes #55

Closed Luminiscental closed 8 years ago

Luminiscental commented 8 years ago

At the moment, only the last PostEffectsPass in PostEffects' m_Passes is actually rendered. To fix this you could change this:

target->Bind();
API::SetActiveTexture(GL_TEXTURE0);
source->GetTexture()->Bind();

quad->Bind();
indices->Bind();

for (PostEffectsPass* pass : m_Passes)
    pass->RenderPass(target);

indices->Unbind();
quad->Unbind();

to this:

target->Bind();
API::SetActiveTexture(GL_TEXTURE0);
source->GetTexture()->Bind();

quad->Bind();
indices->Bind();

m_Passes[0]->RenderPass(target);

target->GetTexture()->Bind();

for (uint i = 1; i < m_Passes.size(); i++)
    m_Passes[i]->RenderPass(target);

indices->Unbind();
quad->Unbind();