global coordinates

How do I get a vertex’s global coordinates after I do severl PushMatrix/translate,multmatrix,scale, etc.

for example (psudocode)

glLoadIdentity
glPushmatrix
gltranslate
glrotate

glPushMatrix
glscale
glMultMatrix

glVertex3f X, Y, Z

glPopmatrix
glPopMatrix

how do I get X,Y, and Z where they would appear in global coordinates?

If you’re interested in performance, then shadow all those matrix calls into your own data structure. Then, you multiply your vertex position by them. Problem solved.

Hmm… I was hoping for something simpler, but I suppose I could do that, since most of my translation and transformation code is done with MultMatrix anyway. Time to brush up on my matrix multiplication skilz.

Ok, so once I have the modelview matrix, how do I use that to translate the local coordinates back into global coordinates?