PDA

View Full Version : how to use glreadpixel() ?



M77ATTAR
11-13-2012, 11:06 AM
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

uwi2k2
11-14-2012, 06:59 AM
hi,



-- 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?


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

V-man
11-15-2012, 04:59 AM
Use gluProject. It gives window's space coordinates for each vertex.