glReadPixels problems again

I have a textured scene and I read the frame buffer using:

glReadPixels (0, 0, winWidth, winHeight, GL_RGB, GL_UNSIGNED_BYTE,

Than I write them in TGA format and mostly everything is OK. Mainly I
get the correct images.

Anyway if I change only the texture files - sometimes only rotate a
texture image in an external program- I get distorted images (starting
from below some parts are good and than some are shifted in horizontal

  1. something strange is happening inside glReadPixels?
  2. it is hardware-dependent - I get differently distorted images on
    different computers

Thank you for your wish to help me but it doesn’t work!
1. glFlush has nothing to do with it but I
tried it anyway!
2. the same for glPixelTransfer!

Two more conclusion from the tests I made:

  1. The problem occures ONLY for textured images (and not always as I
    have already described)!

  2. The glCopyPixels is working properly so the problem is in transfering
    the data into the processor memory!
    I have set GL_PACK_ALIGNMENT to 1 (glPixel Store) but that doesn’t help
    I don’t see any solution ?

                      Please HELP!!!

Just to clarify something - are you sure that it’s the glReadPixels causing the problem, rather than the TGA writing code? If you write the pixels straight back to the framebuffer, do you see the same distortion?

The problem occurs also undes some other views at the scene.
As I wrote , the glCopyPixels works perfectly so the problem is in transfering
the data to processor memory. Somehow some values from the framebuffer can not
be properly converted and transfered to the memory? Also not the whole image is
distorted but only parts of the image.

I have just tried to do glReadPixels and than glWritepixels - the image is not
distorted but it gets darker. I have to think about that.

Look Mike, as I wrote the problem can occur when I just rotate a texture image that is loaded and don’t change the program. I mainly get good images so it doesn’t seem logical to that there is a problem is saving the TGA file since it mostly works good.

Do you wear glasses??

What you said isn’t comprehensible to my knowledge…

OK, maybe I was not completely clear but I’ll continue.
If I do


It works fine…
So the problem is somewhere in saving it to disk. But I can’t see what could that be, and why it should not work only sometimes.
Finally, I think that problems occur only when I use GL_MODULATE for the texture mapping (and of couse some lights).
It seams like there are some pixels that are converted into some format known only for the openGL (for example something like Not aNumber) and that when I write it to disk (a simple proces - there can’t be many errors here) it is distorted because I expect 3 GLBytes for per pixel.

maybe you were getting 4?


		glReadPixels(0,0,640,480,GL_RGBA,GL_UNSIGNED_BYTE, surface);