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


impementing my own glPush and PopMatrix?

Recommended Posts

nitro110    122
I have an assignment where I have to write a program for my graphics class. We have to implement all our own functions, we cant use glRotate, glTranslate,..... I''ve got everything working, but am having trouble writing my glPush and Pop matrix. Any hints or help would be appreciated. Thanks.

Share this post

Link to post
Share on other sites
ZealousElixir    256
Keep a global linked list of matrices. Do this by writing an acyclic linked list class, then deriving a linked matrix class, adding the needed matrix functionality. When you Push, simply put the current matrix on the head of the linked list, and set the matrix stack pointer (which will be of type LinkedMatrix*) to the most recent addition. When you Pop, unlink the head of the list, and set the stack pointer to the former head''s Next pointer. If your design doesn''t allow you to just plug in a new matrix class, you can always just copy the data into the linked matrix object, then add this to the list, as long as you keep track of dynamic allocation.

Just ask if you need further clarification. I''m sure this isn''t the best way by far. There''s probably a boost or STL stack solution that would be neater for what you''re doing. It''s just the first thing that popped into my head, and it seems reasonable.


//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

Share this post

Link to post
Share on other sites