e.g.:
float rgb[3];
glReadPixels(x, y, 1, 1, GL_RGB, GL_FLOAT, rgb);
One caveat: as I recall, you actually had to flush the buffer before it would read correctly, otherwise it would always return (0,0,0) (black). This caused my floodfill to be extreeeeemely slow. The wrapper function idea would definitely work faster. (Anyone know if there's a way to check the frame buffer without having to redraw the screen?)
Lars Olson wrote:
glReadPixels will do the trick, although it's also a little unwieldy, as it only returns one color component at a time.
e.g.:
float red;
glReadPixels(x, y, 1, 1, GL_RED, GL_FLOAT, &red);
// repeat for GL_GREEN and GL_BLUE
Lars
Michael Ryan Byrd wrote:
According to my 455 class you *can*, but it's difficult.
If I remember correctly, we used glutGetColor(int cell, int component)
http://www.opengl.org/developers/documentation/glut/spec3/node67.html#SECTIO
N00092000000000000000
in retrospect, it turned out to be unwieldy, so we made wrapper functions
anyway.
Cheers,
Ryan
----- Original Message -----
From: "David Smith" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, February 01, 2003 2:22 PM
Subject: Re: [uug] OpenGL help
Doesn anyone know of a way to have openGL return a pixel color?
According to my 455 class, you can't. You must store the pixel colors
yourself. Put another way, you can't query the screen to see what color a
pixel is. This is most likely because OpenGL supports floats for pixel
coordintes. Ie, you can say glVertex2f(float x,float y) to turn on a
pixel. For it to store all the different colors for every possible float
value on your screen would be an enormous piece of memory.
It seems to be best to write a wrapper function to OpenGL's pixel
illuminating function and store the pixel's coordinates (use ints) and its
color (floats are okay).
--Dave
____________________
BYU Unix Users Group
http://uug.byu.edu/
___________________________________________________________________
List Info: http://phantom.byu.edu/cgi-bin/mailman/listinfo/uug-list
____________________
BYU Unix Users Group http://uug.byu.edu/ ___________________________________________________________________
List Info: http://phantom.byu.edu/cgi-bin/mailman/listinfo/uug-list
____________________
BYU Unix Users Group http://uug.byu.edu/ ___________________________________________________________________
List Info: http://phantom.byu.edu/cgi-bin/mailman/listinfo/uug-list
____________________
BYU Unix Users Group http://uug.byu.edu/ ___________________________________________________________________
List Info: http://phantom.byu.edu/cgi-bin/mailman/listinfo/uug-list
