Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

supagu

getting current top of stack?

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

i want to get the amtrix from the top of the stack, and set the matrix on the top of the stack, not get the whole stock after it has bee multiplied? ideas? also is the OGL matrix layoud out as follows: m[0] m[4] m[ 8] m[12] m[1] m[5] m[ 9] m[13] m[2] m[6] m[10] m[14] m[3] m[7] m[11] m[15] ? translation being 12, 13, 14? [edited by - supagu on February 27, 2004 9:21:53 PM] [edited by - supagu on February 27, 2004 9:22:16 PM]

Share this post


Link to post
Share on other sites
Advertisement
To get the matrix from the top of the stack you simply do

glPopMatrix();
glGet(GL_MODELVIEW_MATRIX /*or whatever your current matrix mode is*/);

To set the matrix on the top of the stack you do

glLoadMatrix();
glPushMatrix();

The matrix stack never gets multiplied with anything. I guess what you mean is if you call glRotate() your _current_ matrix (this has nothing to do with the stack) gets multiplied with the rotation matrix.

12,13,14 is the scaling vector.

eloso

Share this post


Link to post
Share on other sites
supagu - you seem not to understand how the matrix stack works. The current transformation matrix is *not* a combination of the different matrices on the stack. The stack is only there to let you ''undo'' transformations, by reverting to a previously saved transformation matrix.

Whenever you do a transform (glTranslate, glRotate, glScale, glMatrixMultiply ...) the matrix at the top of the stack gets modified. The stack itself is not affected.

When you call glPushMatrix, the top matrix get duplicated, adding an entry to the stack. The matrix itself is unchanged.
When you call glPopMatrix, the top matrix is discarded, and you revert to the one that was previously stored.

There is absolutely no way to decompose a transformation matrix into each and every transformation you applied since the last time you set the matrix to the identity. At best, you can extract a rotation, a translation and a scaling factor.

Finally, yes, I do believe you got the matrix layout right.
Eloso - no, that''s not the scaling factor.


“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”
— Brian W. Kernighan (C programming language co-inventor)

Share this post


Link to post
Share on other sites
quote:
Original post by Fruny
Eloso - no, that''s not the scaling factor.


Yes, of course you are right. Don''t know how i came to that. Sure it is translation.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!