GLUUNPROJECT(3G)

πŸ“¦ version 1.1, in centos-stream 9, fedora 43, fedora 44

πŸ’– GLUUNPROJECT(3G) πŸ’–

okay bestie, welcome to the gluUnProject page β€” it's in the 3G manual section (that's the GLU utility library zone, iykyk) and it's literally about turning your screen coords back into 3D world coords. we're doing reverse math today and it's giving main character energy ✨


✨ NAME ✨

gluUnProject β€” map window coordinates to object coordinates πŸ¦‹

like, you give it where something is on the screen, and it tells you where that actually is in your 3D scene. the un-do button for projection, fr fr.


🌸 C SPECIFICATION 🌸

GLint gluUnProject( GLdouble winX,
                    GLdouble winY,
                    GLdouble winZ,
                    const GLdouble *model,
                    const GLdouble *proj,
                    const GLint *view,
                    GLdouble* objX,
                    GLdouble* objY,
                    GLdouble* objZ )

copy it exactly, bestie, every GLdouble and * matters πŸ’…


πŸŽ€ PARAMETERS πŸŽ€

  • winX, winY, winZ β€” the window coordinates you wanna map. yes, all three, we're being thorough.
  • model β€” the modelview matrix. you'd grab this from a glGetDoublev call, no cap.
  • proj β€” the projection matrix. also a glGetDoublev situation.
  • view β€” the viewport. this one comes from a glGetIntegerv call, okurrr.
  • objX, objY, objZ β€” not inputs, bestie, these are the returns. the computed object coordinates land here. 🫢

πŸ’œ DESCRIPTION πŸ’œ

so gluUnProject maps the specified window coordinates into object coordinates using model, proj, and view. the result gets stored in objX, objY, and objZ.

and listen β€” the return value is doing a whole vibe check:

  • return GL_TRUE = success, we ate πŸ’…
  • return GL_FALSE = failure, it's giving flop 😭

to compute the coordinates (objX, objY, and objZ), gluUnProject multiplies the normalized device coordinates by the inverse of model*proj as follows:

                    objX
                   ⎝objY⎠=INV(PM)⎝_______________βˆ’1⎠
                    objZ          _______________βˆ’1
                     W                2(winZ)βˆ’1

(that's the formula, transcribed faithfully, go off king)

  • INV() denotes matrix inversion. that's it, that's the whole notation.
  • W is an unused variable, included for consistent matrix notation. it does nothing, it's just there for the aesthetic 🌈
heads up: W is literally unused. don't go looking for meaning in it. it's decorative. like a bow. πŸŽ€

πŸ‘‘ SEE ALSO πŸ‘‘

  • glGet(3G)
  • gluProject(3G)

and that's the whole page, bestie β€” GLUUNPROJECT(3G) in the 3G manual, same title front and back because symmetry is iconic. go un-project something gorgeous. periodt. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from