PDA

View Full Version : window coordinates in glReadPixels



Acheum
03-23-2003, 11:44 PM
Hello,
In the glReadPixels function, I'd like to know what are exactly the windows coordinates parameters x and y. Are they coordinates in pixels, or relative coordinates ? what are the values for the corners of the screen ?
I want to get the full screen in a 64*64 pixels array, what parameters may I use ?
Thanks for your help !

oliii
03-24-2003, 02:31 AM
they are the coordinates in pixels.

top-left corner of the frame buffer is (0, 0)
bottom-right corner is (window_w, window_h)

window_w is the width of the window, window_h is the height of the window.

this is what I would try.






// copy back buffer into the top left area of the auxiliary buffer
GLint NumAuxiliaryBuffers;

glGetIntegerv(GL_AUX_BUFFERS, &NumAuxiliaryBuffers);

if (NumAuxiliaryBuffers < 1)
return 0;

glReadBuffer(GL_BACK);
glDrawBuffer(GL_AUX0);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelZoom(64 / (GLfloat) window_w, 64 / (GLfloat) window_h);
glRasterPos2i(0, 0);
glCopyPixels(0, 0, window_w, window_h, GL_AUX0);

// read the auxilary buffer into the main memory
GLubyte Frame[64][64];
glReadBuffer(GL_AUX0);
glDrawBuffer(GL_BACK);
glReadBuffer(0, 0, 64, 64, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*) Buffer);


[This message has been edited by oliii (edited 03-24-2003).]

[This message has been edited by oliii (edited 03-24-2003).]

Bob
03-24-2003, 03:33 AM
top-left corner of the frame buffer is (0, 0)
bottom-right corner is (window_w, window_h)

No, bottom left corner is (0, 0), and top right corner is (window_w - 1, window_h - 1).