PDA

View Full Version : glDrawPixels & glReadPixels



rIO
09-11-2000, 01:29 AM
I'm trying to paint a small box in a corner of mine rendering with a copy downscaled of the main picture.
I used glCopyPixel to read data from the current rendering and glDrawPixels and glPixelsZoom to redraw a stretched image in the lower corner.
But nothing happens, I'm using a double buffer but I can't see anything...

mine code is just

glCopyPixels();
glPixelZoom();
glDrawPixels();

I've also tryied to change the reading/writing parameters to GL_FRONT, GL_LEFT and so on, but nothing seems to change...

the coordinates passed are right, do someone can explain me where is the mistake ? Or have some ideas on how make me find the error ??

Thanks.

[rIO]

Relic
09-11-2000, 03:32 AM
The inverse operation to glDrawPixels is glReadPixels. Both calls use data from the host memory.
With glCopyPixels you can move data around among drawbuffers buffers directly.
You can downscale the image with glPixelZoom and set the destination with glRasterPos.

Means you need only something like this:
glReadBuffer(GL_BACK); // Change to where your source image is.
glDrawBuffer(GL_BACK); // Change to where the destination image should be(?) (default with double buffer)
gluOrtho2D(0, width-1, 0, height-1); // left, right, bottom, top
glPixelZoom(0.25, 0.25); // 1/16 image size
glRasterPos2i(0, 0); // lower left
glCopyPixels(0, 0, width, height, GL_COLOR);

I think the driver should be smart enough to figure out the copy directions if the source and destination rects overlap.


[This message has been edited by Relic (edited 09-11-2000).]