How can i have my program return an RGB value dependant upon where the mouse is?

Thanks in advance.

I mean dependant upon which pixel the mouse is over.

The easiest way I can think of right off hand would be to read back the frame buffer and find our for yourself
There’s a feedback buffer but from what I read that’s supposed to be a little tricky and expensive, so I’d do

GLubyte rgb[3];
glReadPixels(mouseX, mouseY, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &rgb[0]);