• Advertisement

Archived

This topic is now archived and is closed to further replies.

Colour Picking..

This topic is 5939 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! How can I pick colour in OpenGL? e.g. I want to get colour of pixel from center of screen. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
all you need to do is:

unsigned char pixels[3]; // Red, Green, Blue
glReadPixels( xcenter, ycenter, 1, 1, GL_RGB, GL_BYTE, (void*)&pixel);

this reads the pixel at ''xcenter'', ''ycenter'' and puts it in the ''pixels'' arrary.

if you want to do this from the back buffer, you have to first call:

glReadBuffer(GL_BACK);

this will read from the back buffer, but only if you have a double buffered window.

if you can''t get this to work, e-mail me at focus_business@hotmail.com, and i''ll send you the code to do it, as i had the same problem (but using mouse coordinates).

Share this post


Link to post
Share on other sites

  • Advertisement