how to use glreadpixel() ?

hello,

I just draw a rectangle as follows:

glColor3f(1.0,.0,.0);
glBegin(GL_POLYGON);
glVertex2f(.0,.0);
glVertex2f(0.2,.0);
glVertex2f(0.2,1.0);
glVertex2f(.0,1.0);
glEnd();

my questions is:

– what is the x,y, width and height adequate for glReadPixels(x,y, width,height,GL_RGB,GL_UNSIGNED_BYTE,data);
to retrieve only the color red (rectangle) knowing that the points of the rectangle are of type float?

–how to retrieve the values ​​of the parameter data, and save them in a text file ?

cordially

hi,

you can´t do a 1 to 1 merging from the vertex data to screen coordinates.
there are complex math forms that can do that.
sorry i cant help you more, but you may search for ‘world coordinates to screen coordinates’.

cu
uwi

Use gluProject. It gives window’s space coordinates for each vertex.