I am trying to draw over a GL_TRIANGLE_FAN one texture to render video frames, using shaderProgram1, and render above it some points (GL_POINTS) using shaderProgram2.
By this way: (OpenGL Core 4.3)
void GLViewer::paintGL()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glUseProgram(handleShaderProg1);
glUniform...(); //Set Uniforms for shaderProg1... <-- FIXED
glBindTexture(GL_TEXTURE_2D, textureHandle); //Bind texture
glBindVertexArray(vaoHandle1); //Bind VAO
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glBindVertexArray(0); //Unbind VAO
glBindTexture(GL_TEXTURE_2D, 0); //Unbind texture (used in shaderProg1)
glUseProgram(handleShaderProg2);
glUniform...(); //Set Uniforms for shaderProg2... <-- FIXED
glBindVertexArray(vaoHandle2); //Bind VAO
glDrawArrays(GL_POINTS, 0, 25);
glBindVertexArray(0); //Unbind VAO
}
But only the points defined in vbo2 are rendered over the black glClearColor. Without using the shaderProgram2, all are rendered, texture and the points above it.
Is mandatory to use a FBO and two pass deferred rendering? If not, what could be the problem?
SOLVED : After an OpenGL debugging, I discovered a newbie bug...
In my case, I needed to pass the uniforms to the shader every time the current shader program will be changed to another shader program. I was thinking that the uniform variables will keep alive after another call to glUseProgram. I was wrong...
texture->bind()
,texture->unbind()
andvbo*->render()
definitions. We need to know raw GL calls. To debug rendering issues, you could use graphics debugger tools, to see exact GL calls order. For example, NSight if you have NVidia GPU. \$\endgroup\$