Saving/restoring opengl matrix stack

Hi all,

I am trying to allow unmanaged code (via ofxPython) to my application, that involves arbitrary user-gerenated sequences of drawing commands, such as ofPushMatrix, ofPopMatrix etc…

I am having the trouble that when the user leave unmatched ofPushMatrix / ofPopMatrix, all the program enters in a wrong state and can’t draw anything.

Is there any way to save and restore the matrix stack, so I don’t care if there are unmatched matrix push/pop operations?

Does this work for you?

ofMatrix4x4 m = ofGetCurrentViewMatrix();
ofTranslate(0,1999);
ofScale(55,42);
ofLoadMatrix(m);

Good Idea! If I don’t use ofPushMatrix or ofPopMatrix in managed code I don’t care for unmatched push/pop operations :smile:
The only problem is: I am using OF v0.8.4 and this function is not implemented, but I guess I can replicate it.