Sign in to follow this  

[2D] Getting the current position vector.

This topic is 3575 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
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

This topic is 3575 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this