   Where should I use gluProject/gluUnproject?
  I've been considering using gluUnProject for picking. If I run it outside of my rendering loop, it doesn't work (presumably because the modelview and projection matrices are different). Should I be running it inside my rendering loop and perhaps storing 'screen' coordinates with the object?I'm away from my code right now, so I can't provide exact examples. In fact, I hope that I'm not trying to use gluUnProject while in my HUD's orthogonal mode. That would be really stupid of me. Actually, come to think of it, that's probably what I'm doing. GAH! That explains why the camera Z position wasn't taking effect. [crying] I'll make sure that isn't what I'm doing, but for now I should probably get my first question answered so I can clean up my code a bit.Also: barring gluUnProject, is there a nicer way to do picking that doesn't involve rendering the same scene twice?   
Quote:I've been considering using gluUnProject for picking. If I run it outside of my rendering loop, it doesn't work (presumably because the modelview and projection matrices are different). Should I be running it inside my rendering loop and perhaps storing 'screen' coordinates with the object?As far as i know gluUnProject uses the matrices you pass to it. If those matrices are correct then the result will be correct. In other words, it doesn't call glGetDoublev() for MODELVIEW_MATRIX and PROJECTION_MATRIX. It just uses what you give it. So it doesn't really matter where you call it, if the matrices are correct.If it works as expected when you call it from inside the rendering loop, but not from outside, then i suggest keeping the matrices somewhere for later use.Quote:Also: barring gluUnProject, is there a nicer way to do picking that doesn't involve rendering the same scene twice?If you don't want to render extra things, the only other way i can think of is ray casting.HellRaiZer   ;  How would ray casting work? Wouldn't I need to translate the screen coordinate to a world coordinate to start the ray anyway?   ;Quote:How would ray casting work? Wouldn't I need to translate the screen coordinate to a world coordinate to start the ray anyway?My fault. Of course you need a second point in case to make the direction vector. Sorry for that! HellRaiZer   ;  Since you say that the matrices are different I would suggest storing a copy of the matrices in your obects that way you can do the gluUnproject tests inside of your mouse handling routines.   