Color detection

Hi guys
I have make some simple maps with glrect(…) with colors and i create also one sphere to walk on the map from one direction to another, i want my sphere detect what color is glrect() so i cant control and restrict how my sphere should move in map created. Please help, because what i just know for color detection is with mouse and i dont want it, because i will move the sphere with keyboard.

Thanks

Hmm, I must be misunderstanding something, but if you know how to determine the color at the mouse’ position, what is the difference to determining the color at the sphere position?
Besides, if your map consists of colored rectangles can’t you use the rectangles coordinates and the sphere center to calculate which rectangle you are in?