Forums > Jitter

Why use glpushmatrix/gl popmatrix when, for instance, glrotating?

February 19, 2013 | 6:59 am

I’m trying to get a better grip in the gl commands to send to jit.gl.sketch. So: In the Jitter tutorials, we’re told how to rotate an sketched shape, and to do so we need to use ‘glmatrixmode modelview, glpushmatrix, …, gl popmatrix’. However, the glrotate command seems to work without these. Why do we need the push and popmatrix commands? Like I said, just trying to understand! I can’t quite get the explanation the tutorials give. Thanks for your help.


February 19, 2013 | 6:55 pm

opengl operates as a state machine, so any command you send changes the state for all subsequent commands.

additionally transform commands (rotate, translate, scale) concatenate together to get the final transform.
pushmatrix and popmatrix allow you to modify the transform, without affecting subsequent transform states.

if you transform messages are intended to affect all subsequent draw calls, you won’t need push and pop.

yes it’s confusing, this is why we’ve abstracted a lot of this with the jit.gl and jit.anim objects,
as of max 6, there should be very little need to delve into low-level opengl calls.
unless you enjoy the pain!


Viewing 2 posts - 1 through 2 (of 2 total)