Im using glut, is there a way I can click on the screen, and get the RGB value of the pixel that I clicked on?
-obtain the mouse location in window coordinates (pixels)
pixel will hold your pixel color
note that XXXpixels() functions are a bit slow…
[This message has been edited by dmy (edited 03-09-2000).]
You can use void glReadPixels( GLint x,GLint y,GLsizei width,GLsizei height,GLenum format,GLenum type,GLvoid *pixels )
Used with void glutMouseFunc(void (*func)(int button, int state, int x, int y)) you can do like this.
mousefunc(int button, int state, int x, int y))
glReadPixels(x, y, 1, 1, GL_RGB, GL_FLOAT, &pixel);
Before you call glutMainLoop() you have to call glutMouseFunc(mousefunc)
Everytime you press the left button on the screen, you will get the rgb values in the variable pixel.
Might not work that well since I’m not able to try it out right now…
I’ll give that a try, thanks.