I’m trying to implement post processing effects in OpenGL by drawing a quad ( 2 tri) texture that replicates the screen but it is using the wrong shader
I’m not very experienced with OpenGL but I think glUseProgram() makes the window use the shader program of input but it doesn’t work. I’m using this guy’s tutorial: https://www.youtube.com/watch?v=atp3bzebWJE&t=561s and I’m pretty sure the error is somewhere in the render loop
code:
while(!glfwWindowShouldClose(window))
{
glUseProgram(defaultShader.program); // uses the normal shader
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
glClearColor(0, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT);
glBindVertexArray(VAO.buffer); // VAO is for a test triangle
glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT,0); // drawing test triangle
glBindVertexArray(0);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glClearColor(0.4, 0.8, 1, 1);
glClear(GL_COLOR_BUFFER_BIT);
glUseProgram(frameShader.program); // framebuffer shader
glBindVertexArray(quadVAO); // the quad's VAO uses x y and texturec ooordinates
glUniform1i(glGetUniformLocation(frameShader.program, "screenTexture"), textureColorbuffer); // not explicitly said in tutorialbut probably needed for the uniform^^^^
glBindTexture(GL_TEXTURE_2D, textureColorbuffer);
glDrawArrays(GL_TRIANGLES, 0, 3);
glfwSwapBuffers(window);
glfwPollEvents();
}