gluUnProject will always return zero and posX/Y/Z will also always be zero. I'm calling gluUnProject with some test data instead of a mouse position for the sake of a test case that I can share and is easy to interpret.

void Renderer::DrawGLScene( void ) { glLoadIdentity(); GLint viewport[4]; GLdouble modelview[16]; GLdouble projection[16]; GLfloat winX=0, winY=0, winZ=0; GLdouble posX=0, posY=0, posZ=0; glGetDoublev( GL_MODELVIEW_MATRIX, modelview ); glGetDoublev( GL_PROJECTION_MATRIX, projection ); glGetIntegerv( GL_VIEWPORT, viewport ); gluUnProject( 123, viewport[3] - 45, 0, modelview, projection, viewport, &posX, &posY, &posZ); return; }

this is called one time at program start

void Renderer::ResizeGLScene( const int width, const int height) { if ( height==0 ) res.y=1; else res.y=height; if ( width==0 ) res.x=1; else res.x=width; game->sdl.SetVideoMode( width, height, fullscreen, 32, 0 ); glViewport(0,0,res.x,res.y); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(90.0f,(float)res.x/res.y,0.0f,600.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); SDL_PumpEvents(); }

**Edited by caibbor, 24 May 2012 - 07:34 PM.**