Jump to content
  • Advertisement
Sign in to follow this  
MadsGustaf

[2D] Getting the current position vector.

This topic is 3732 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello. I have set up a projection matrxi, so this is in 2d. After having done several translation and rotations, i would like to get the current position that is the origin for further drawings before calling glLoadIdentity()/popback. How would i do this?. [Edited by - MadsGustaf on April 1, 2008 4:25:29 PM]

Share this post


Link to post
Share on other sites
Advertisement
float mat[16];
glGetFloatv(GL_MODELVIEW_MATRIX, mat);

The final four components of mat are the position vector of the current modelview matrix. If you do the same for the projection matrix, I believe adding the reverse of that vector to the modelview position vector will give the final world origin.

Share this post


Link to post
Share on other sites
call the following:
float mat[16];
glGetFloatv(GL_MODELVIEW_MATRIX, mat);

Now to get your x,y,z coordinate look at:
x = mat[12];
y = mat[13];
z = mat[14];

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!