Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am making a simple game engine for a simple RTS game and would like to be able to pick a cube and move it around with the mouse coordinates. The problem is that my camera is rotated 60 degrees just like any RTS game and I am not sure how to use gluUnProject..

Thanks in advance!!

share|improve this question
What were your problems using gluUnproject? Didn't you know what values to provide for some of the parameters or was it something else? –  Roy T. Nov 14 '12 at 12:43
Simply the 60 degrees tilting. I would like to get the correct z value to move objects –  SPL Nov 14 '12 at 13:46
How to pick objects in 3d is a topic of its own, but as far as gluUnProject goes it's not too difficult: just plug in the same matrices as you used when rendering! gluUnProject(winX, winY, winZ, modelViewMatrix, projectionMatrix, viewport, &objX, &objY, &objZ) will convert from window coordinates to world coordinates. Window coordinates should be normalized device coordinates (0..1 range, winZ is the value from the depth buffer). –  ccxvii Nov 14 '12 at 15:59
Look at picking tagged questions. –  ErikEsTT Nov 15 '12 at 7:17
Thank you. Picking is not good for this, or at least I didn't find anything that could give me not a face but a point on a face's surface. –  SPL Nov 20 '12 at 16:33
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.