How would I generate a model view matrix using GLKit's GLKMatrixStack library?
-
11-12-2019 - |
Question
There is a header file in GLKit with the following comment:
GLKMatrixStack is a CFType that allows for the creation of a 4x4 matrix stack similar to OpenGL's matrix stack. Any number of matrix stacks can be created and operated on with functions similar to those found in fixed function versions of OpenGL.
How would you go about generating a model view matrix based on the contents of the stack? I can't find any reference to the GLKMatrixStackRef
type outside of the GLKMatrixStack
header.
Solution
In Apple's C libraries, <whatever>Ref
is a typedef for a pointer to <whatever>
. So the appropriate documentation is that for GLMatrixStack. So you'd use GLMatrixStackCreate
, then whatever combination of GLMatrixStackRotate
, GLMatrixStackScale
, GLMatrixStackPush/Pop
etc and something like GLMatrixStackGetMatrix4
when you want to communicate the results to your shaders.