Skip to main content
gamedev.net
🔒 Locked

Colour Picking..

Started by Rohirm Oct 17, 2001 at 2:49 AM 0 replies 250+ views
Original Post
Rohirm
Rohirm
Hi! How can I pick colour in OpenGL? e.g. I want to get colour of pixel from center of screen. Thanks!
davekerr
davekerr
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).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.