marcelnijman
marcelnijman

Reputation: 604

How to save the transform matrix in GLKit?

In iOS 5, with EAGLView, you can do:

glPushMatrix();
glTranslatef(x, y, 0.0f);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glPopMatrix();

With GLKView, is this replaced by the following?

GLKMatrix4 t = self.effect.transform.modelviewMatrix;

self.effect.transform.modelviewMatrix = GLKMatrix4Translate(t, x, y, 0);
[self.effect prepareToDraw];

glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

self.effect.transform.modelviewMatrix = t;

Kind of ugly...

Upvotes: 1

Views: 528

Answers (1)

Jim Hillhouse
Jim Hillhouse

Reputation: 159

Check out GLKMatrixStack. I use this for building hierarchical models in GLKit.

Upvotes: 3

Related Questions