The smallest source I could come up with is several hundred lines, and I don’t know how to post it acceptably. However, the framebuffer object code I use is taken almost directly from the example here: http://www.gamedev.net/reference/programming/features/fbo1/ (I just cut out the mipmapping.) I created a simple example from that code, and it shows the same behavior.
In main, I added an option to load shaders or not. If not loaded, the code execution is pretty much like the example. If loaded, main loads the shader code, checks for errors, and gets the location of the sampler2D “Image” in the shader program.
Then in the display function, if I’m using the shaders, I set the active texture to 0 and bind the FBO texture, as you have, then set the location of “Image” to 0. The vertex shader code is
00001 varying vec2 TexCoord;
00002
00003 void main ()
00004 {
00005 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
00006 TexCoord = gl_MultiTexCoord0.xy;
00007 }
and the fragment shader is
00001 uniform sampler2D Image;
00002 varying vec2 TexCoord;
00003
00004 void main (void)
00005 {
00006 vec4 base_color;
00007
00008 base_color = texture2D (Image, TexCoord);
00009 gl_FragColor = base_color;
00010 }
When I run the program without the shader, it works exactly as the example code. With the shader, I get a texture that’s uniformly black - or some other color if I explicitly set the value of gl_FragColor to e.g. vec4 (1.0, 0.0, 0.0, 1.0), so the shader is being called and doing something.
What appears to be happening is that the fragment shader just isn’t getting anything for the Image sampler, but I can’t see why, because it works as a texture outside the shader. But again, if I use the same shader code and setup with a texture that I’ve read in from a file, it works.