December 31, 2001, 7:48pm
I created an object by the combination of large number of triangles using glBegin function. My question is how to get the x & y(z if possible)OpenGL coorinates of the mouse clicked point to put a color in the clicked point? not the X & Y screen points in the mouse click .Is it possible ?
Pls help me if any one knows.
Thanks in advance for Ur replay
I think what you need is to use the selection buffer. Its explained in the opengl superbible and the redbook. Im sure there are tutorials on the subject as well.
[This message has been edited by SirKnight (edited 12-31-2001).]
i would recommend building a ray from the camera position along the clicked point, and cutting the ray with the triangles.
building the ray is easy, use gluUnProject();
January 1, 2002, 12:23pm
glReadPixels (x_2d, y_2d, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z_2d);
if (z_2d > 0.9) z_2d = 0.9;
gluUnProject ((GLdouble) x_2d, (GLdouble) y_2d, (GLdouble) z_2d,
modelview, projection, viewport, x, y, z);