Write and Test blur()
main.cpp
blur()
void blur(int pass)
{
GLuint loc = glGetUniformLocation(bloomblurShader, "pass" );
glUniform1i(loc, pass);
glActiveTexture(GL_TEXTURE2);
if ((pass % 2) == 0)
{
// rending from texture 1 and writing to texture 2
glBindTexture(GL_TEXTURE_2D, blurtex[0]);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, blurtex[1], 0);
}
else
{
// reading from texture 2 and writing to texture 1
glBindTexture(GL_TEXTURE_2D, blurtex[1]);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, blurtex[0], 0);
}
// Render the full-screen quad
square->setShaderId(bloomblurShader);
square->draw(glm::mat4(1.0f), glm::mat4(1.0f), glm::mat4(1.0f));
}init shaders in the shader section in main()
call blur() in the event loop
Test blur()
Last updated