Hi,
I'm trying to select a object in my 3D world. I looked online a bit and u found that you can use gluUnProject, but i don't understand how it works.
I Currently have this code:
double modelMatrix[16];
double projMatrix[16];
GLint viewport[4], winZ;
glGetDoublev(GL_MODELVIEW_MATRIX,modelMatrix);
glGetDoublev(GL_PROJECTION_MATRIX,projMatrix);
glGetIntegerv(GL_VIEWPORT,viewport);
GLdouble posX, posY, posZ;
glReadPixels( x, int(y), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ );
gluProject(x,y,winZ,modelMatrix,projMatrix,viewport,&posX,&posY,&posZ);
gluUnProject(x,y,winZ,modelMatrix,projMatrix,viewport,&posX,&posY,&posZ);
X, y and Z are my mouse position
And when i check after gluProject the numbers are huge, and after gluUnproject they are between -1 and 1(screen i gues).
But the x, y and z coordinates of my objects aren't near the numbers i'm getting back. Do i need to do a nother calculation?
Thanks for the help in forhand.