I’m not sure how to use the Unproject method provided by GLM.
Specifically, in what format is the viewport passed in? And why doesn’t the function require a view matrix as well as a projection and world matrix?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A bit of history is required here. GLM’s unproject is actually a more or less direct replacement for the
gluUnProjectfunction that uses deprecated OpenGL fixed-function rendering. In this mode the Model and View matrix were actually combined in the “ModelView” matrix. Apparently, the GLM author dropped the ‘view’ part in the naming, which confuses thing even more, but it comes down to passing something likeview*model.Now for the actual use:
(x,y)When applied you simply end up by converting the provided window coordinates back to the object coordinates, more or less the inverse of what your render code usually does.
A half-decent explanation on the original
gluUnProjectcan be found as a NeHe article. But of course that is OpenGL-specific, while glm can be used in other contexts.