Hi! I've been struggling with this for quite a while now, mostly in a bit bigger test I had. At first I was rendering a 3D scene directly to screen which worked fine. Then I tried to first render it to an intermediate framebuffer before rendering the framebuffer to screen (as a texture). When I did that, then the scene didn't render to screen anymore. Nothing was rendered to screen. If I would modify the framebuffer texture directly by for example clearing the background to some colour, then that colour would show. Thus, the problem lies in drawing the scene to the framebuffer.
I have now modified my program to be more minimal. I'm simply trying to draw a coloured triangle to screen via a framebuffer. I get the same results: with framebuffer: nothing on screen, without framebuffer: triangle is rendered correctly.
main.cpp: http://sprunge.us/FjAg
Shaders:
For the triangle:
- Vertex (shaders::vert)
#version 150
in vec3 position;
in vec3 color;
out vec3 Color;
void main()
{
Color = color;
gl_Position = vec4(position, 1.0);
}
- Fragment (shaders::frag)
#version 150
in vec3 Color;
out vec4 outColor;
void main()
{
outColor = vec4(Color, 1.0);
}
For drawing the framebuffer texture image thing to screen:
- Vertex (shaders::vert2)
#version 150
in vec2 position;
in vec2 texcoord;
out vec2 Texcoord;
void main() {
Texcoord = texcoord;
gl_Position = vec4(position, 0.0, 1.0);
}
- Fragment (shaders::frag2)
#version 150
in vec2 Texcoord;
out vec4 outColor;
uniform sampler2D texFramebuffer;
void main() {
outColor = texture(texFramebuffer, Texcoord);
}
Thanks in advance.