I have a FBO with a texture which is per default grey. I bind the FBO, do glClear() and now I expect the texture to be red. I do glReadPixels() and I get the correct image data (red imge), but when I do glGetTexImage() I get the grey (default) image data.
Only glCopyTexImage2D() and glTexSubImage2D() seem to change the texture data, all rendering to the FBO doesn’t change the texture as seen by glGetTexImage().
Here’s my test app (works only under linux):
http://dbservice.com/tom/gltest.c
Please make sure your screen resolution isn’t bigger than 1280x1024 when you run this app.
At the bottom of the file there’s __glCapture() which is called in an endless loop… press CTRL+C to abort the app.
You see there that I activate the FBO, glClear(), glReadPixels() to a local buffer, activate the texture, glGetTexImage() to another local buffer and compare the two buffers.
the app prints the first pixel of each buffer, I get this:
textureBuffer 85:85:85:85
frameBuffer 0:0:255:255
which means glReadPixels() returns the correct image data (BGRA), but glGetTexImage() returns BGRA 85:85:85:85 which is in ASCII ‘U’ (like Undefined ?)
glGetTexImage() does not generate any error.
What am I doing wrong?