PDA

View Full Version : How to convert the contents in frame buffer into a 2D array?



powervr
09-16-2004, 03:18 AM
Hi guys,

I would like to know how to convert the content in frame buffer into a 2D array (pixel by pixel)?

e.g. consider the following code:
---------------------------------
glBegin(GL_POLYGON);
glVertex3f (0.25, 0.25, 0.0);
glVertex3f (0.75, 0.25, 0.0);
glVertex3f (0.75, 0.75, 0.0);
glVertex3f (0.25, 0.75, 0.0);
glEnd();
----------------------------------------------
The code above draw a rectangle on the screen,

I would like get the following:

000000000000000000000000000
000001111111111111111100000
000001111111111111111100000
000001111111111111111100000
000001111111111111111100000
000001111111111111111100000
000001111111111111111100000
000001111111111111111100000
000001111111111111111100000
000001111111111111111100000
000000000000000000000000000

Thanks.

Relic
09-16-2004, 04:31 AM
Search for glReadPixels.
If you need it as one bit per pixel use GL_BITMAP as type.
Mind that OpenGL coordinates are bottom-left origin when interpreting your readback data.

powervr
09-16-2004, 05:04 AM
Thanks!