Getting the current projection matrix

Viewed 83

How do I get and set the current projection matrix in Processing (version 4 beta, P3D renderer) ? Processing provides printProjection(); but doesn't provide a way of getting the data. Current transformation matrix can be saved, get and set using pushMatrix(), getMatrix(), and setMatrix(). Is there and equivalent (or a foolproof work around) for projection matrices ?

I searched the javadoc version of the documentation and couldn't find anything.

I attempted to see what printProjection() does in the source code. PApplet.g -> PGraphicsOpenGL.projection -> PMatrix3D and PGraphicsOpenGL.pushProjection. Both objects g and projection are public members.

Origin of this question : I have a class which sets up the camera (It calls camera() and perspective()). I have another class which needs to temporarily reset the transformation and projection matrix so that it can overlay text() on the screen. The transformation matrix can be easily pushed and poped. Is there an equivalent for the projection matrix.

I do not want to manually keep track of the calls to perspective() which sets the projection matrix. One reason is that it will become a burden on the end user and another reason is that I need the original projection matrix set by the size() function to be able to properly place text() on the screen.

0 Answers
Related