Math Library Release
Friday, June 12, 2009 at 9:31PM I've been working on OpenGL ES tutorials for a while and I always hit the same wall: a lack of vector and matrix support. For DirectX there's D3DXVECTOR4 and D3DXMATRIX which make it much easier to get started. For OpenGL you have some support via the matrix stack and glOrthof/glRotatef/etc. but OpenGL ES 2.0 takes even that away from you.
Several years ago I wrote a math library that included everything from sine and cosine to transformations. It's overkill for simple 3D mathematics and a lot of it is organized in preparation to create a ray tracer. MathLib is what I use for all of my own OpenGL rendering, though, and does a good enough job for most cases.
To give back to the community and save myself some sanity moving forward I've decided to release the MathLib part of my code library under the MIT license. Download it, check it out, and try it out. I'll release source code that shows how it's used with OpenGL ES shortly.
[EDIT: here's a quick example on how to use the library's transformations with OpenGL]
glMatrixMode(GL_PROJECTION);
Transform4f ortho(Transform4f::Orthographic(-1.0f, 1.0f, -1.5f, 1.5f, -1.0f, 1.0f));
Matrix4x4f mat(ortho.GetTransform());
glLoadMatrixf((float*)mat);
glMatrixMode(GL_MODELVIEW);
Transform4f rot(Transform4f::RotateZ(rotation * 0.0174532925f));
mat = rot.GetTransform();
glLoadMatrixf((float*)mat);
OpenGL MathLib in
GameProgramming 
Reader Comments