Should have been build-in ( or rather a Camera component ), and could have been a piece-of-cake if doubles were supported ...
In any case, essential for 2D & Isometric games ( and stuff like Paper Mario / Crush / Fez ). Needs to be called from the base-level of the ModelView Matrix, so make sure to pop out of the stack when calling from a Model. Uses the standard Camera properties except from Ratio, and has a added Zoom argument ( instead of FOV ).
Code: Select all
void ortho(float Ratio, float Zoom)
{
float N, F;
N = App.ClipNear;
F = App.ClipFar;
glMatrixMode(0x1701);
glLoadIdentity();
glScalef(Ratio*Zoom,Zoom,-2/(F-N));
glTranslatef(0,0,0.5*(F+N));
glMatrixMode(0x1700);
glLoadIdentity();
glRotatef(App.CameraRotation.X*360,1,0,0);
glRotatef(App.CameraRotation.Y*360,0,1,0);
glRotatef(App.CameraRotation.Z*360,0,0,1);
glTranslatef(0-App.CameraPosition.X,0-App.CameraPosition.Y,0-App.CameraPosition.Z);
}
K