Tell me more ×

If i have a object on plane its translation value is glTranslatef(0,10,-5) so can i assume my object position is (0,10,-5) ? Is translation gives position of objects ?

share|improve this question

1 Answer

No, glTranslatef() sets a Matrix that makes sure that all objects drawn after this statement are translated by the given amount. If you want to translate (position) just one object, use the following.


This code does the following:

First it loads the identity matrix, this literally means no change in position, rotation or scale. Then a new matrix is pushed onto the matrix stack. All changes to the current WorldMatrix will hold until glPopMatrix() is called.

We modify the current world matrix by setting a translation of (0,10,-5) and then we draw that object at that location.

Now we pop the current world matrix, the current world matrix now disappears and we return to the previous WorldMatrix (which was the identity matrix)

Then we draw object two, which is just being drawn at (0,0,0).

share|improve this answer
Thanks i got it. Then how will get the current position of triangle in respect of 3D co-ordinate ? – Ajay_Kumar Apr 2 '11 at 6:53
WorldMatrix * trianglePosition will yield yo the exact 3D position, but you might need to implement your own Matrix Algebra for that. Btw please mark this question as the answer if it helped you ;). – Roy T. Apr 2 '11 at 6:58

Your Answer


