View Full Version : mirroring image buffer

02-07-2005, 09:19 AM

How can I mirror my image buffer before saving? I have to swap the last row of the image with the first and so on.
But how can I do that?

Thanx, Dave

02-07-2005, 09:59 PM
// glReadBuffer and glDrawBuffer identical.
glPixelZoom(1.0, -1.0);
glRasterPos2i(0, height);
glCopyPixels(0, 0, width, height, GL_COLOR);

This might not be super-fast.

02-07-2005, 10:04 PM
But this handles the geometry of the window and I have to mirror the image when it is already painted to save it after that.


02-07-2005, 10:09 PM
There is no way to flip the image WHILE doing a glReadPixels, only before and afterwards.
The code will flip the image you see onscreen (or in the backbuffer) and then you save. There is no geometry involved, just pixel operations.
I forgot that the projection matrix setup needs to be an glOrtho(0, windowWidth, 0, windowHeight, -1.0, 1.0) and modelview identity before the glRasterPos call.
If this is not what you wanted, then you need to do it yourself after you read the data.