In OpenGL ES 2.0, there is no matrix stack. I really do miss the matrix stack, so I decided to take a cue from the Direct3D utility library, where there is a matrix stack class.
My class interface is heavily inspired by the D3D class, but there was no implementation to peek at, so I had to figure out the implementation of the methods on my own. If anyone is interested in the code, I am willing to share.
I have ported most of my game engine to Objective-C, but since the open source GLGX math library I am using is in C++, I decided to write all my math related classes in C++.
#include "GLGXMath.h" #define MAX_MATRIX_STACK_LEVELS 32 class MatrixStack { private: GLGXMATRIX stack[MAX_MATRIX_STACK_LEVELS]; int currentLevel; public: MatrixStack(); void clear(); const GLGXMATRIX *getTop() const; void loadIdentity(); void loadMatrix(GLGXMATRIX *matrix); void multMatrix(GLGXMATRIX *matrix); void multMatrixLocal(GLGXMATRIX *matrix); void pop(); void push(); void rotateAxis(GLGXVECTOR3 *vector, float angle); void rotateAxisLocal(GLGXVECTOR3 *vector, float angle); void rotateYawPitchRoll(float yaw, float pitch, float roll); void rotateYawPitchRollLocal(float yaw, float pitch, float roll); void scale(float x, float y, float z); void scaleLocal(float x, float y, float z); void translate(float x, float y, float z); void translateLocal(float x, float y, float z); };
As is painfully obvious from the lack of posts on this blog, I pretty much abandoned my racing game for the iPhone. However, I still have the code and I am once again motivated to work on it. So here we go!
First of all, I have started to create my 3D content in Cheetah3D. The main reason for this is that Cheetah3D is very easy to use and it is scriptable using Javascript. So far I have created a script that generates a road mesh for me and I have imported meshes from a racing game I created for Windows in 2003.
Below is an image rendered by Cheetah3D, which might not look like much, but I am just getting started!

Hello, my name is Martin Johannesson and this is my home on the web. I live in Stockholm, Sweden, where I work as a software engineer at a software company.
Ever since I was a kid and discovered the art of programming on my
C64,
I've been tinkering with my own little software projects and experiments.
This site is one such experiment.
more...