Write blend()

blend()

In the blend step, we are going to draw directly on the screen instead of render-to-texture.

void blend()
{
    // Bind to the default framebuffer to draw on the screen
    glBindFramebuffer(GL_FRAMEBUFFER,0);

    glClear(GL_COLOR_BUFFER_BIT );
    glViewport(0,0,width,height);

    // Render the full-screen quad
    square->setShaderId(bloomblendShader);
    square->draw(glm::mat4(1.0f), glm::mat4(1.0f), glm::mat4(1.0f));    
}

init shaders in the shader section in main()

We don't need to set eye and light positions because we don't need them for image processing.

    //==============================================================================
    // added for LabA10 Bloom
    bloomrenderShader = initShader("shaders/bloom.vert", "shaders/bloomrender.frag");
    setLightPosition(lightPos);
    setViewPosition(viewPos);

    bloomfilterShader = initShader("shaders/bloom.vert", "shaders/bloomfilter.frag");

    bloomblurShader = initShader("shaders/bloom.vert", "shaders/bloomblur.frag");

    bloomblendShader = initShader("shaders/bloom.vert", "shaders/bloomblend.frag");
    //==============================================================================

call blend() in the event loop

Last updated