Are you aware of a complete (or almost complete) cross platform math library for use in OpenGL ES 2.0 games?

The library should contain:

  • Matrix2x2, Matrix 3x3, Matrix4x4 classes
  • Quaternions
  • Vector2, Vector3, Vector4 Classes
  • Euler Angle Class
  • Operations amongh the above mentioned classes, conversions, etc..
  • Standardly used math operations in 3D graphics (Dot Product, Cross Product, SLERP, etc...)

Is there such Math API available either standalone or as a part of any package?

Programming Language: Visual C++ but planned to be ported to OS X and Android OS.

  • \$\begingroup\$ Related Question: gamedev.stackexchange.com/questions/12601/simd-c-library/12606 \$\endgroup\$
    – legends2k
    May 8 '13 at 19:00
  • \$\begingroup\$ There is no perfect math library for now, I just tried to write few requirements and just no library have them, well in the reality I'd like someone make a library easy as GLM with same function as shaders + the style of Ogre math library and some of its functionalities (that GLM is missin like view frustum, bounding boxes etc.) Also note that GLM is not that fast (in reality that does not matters) so i doubt someone will use it in raytracers or intensive stuff, is more usefull because of its API and design style \$\endgroup\$ Jul 2 '14 at 13:46

Have you considered the Configurable Math Library?

  • \$\begingroup\$ +1 @Josh: Thanks for your good tip. I am currently considering GLM (glm.g-truc.net) GL Math library. I will wait to see what libraries people arlready have tried and have been proven as good. \$\endgroup\$ Feb 7 '11 at 20:28
  • 3
    \$\begingroup\$ Id strongly recommend GLM. I use it and its "awesome" \$\endgroup\$ Feb 8 '11 at 6:45
  • \$\begingroup\$ +1, I like CML a lot and would have posted that as an answer =). It does, however, depend a lot on the optimizations of the compiler, as it's generic and template based. If you're targeting a mobile device (likely as you quoted ES), some other math library may be better optimized for the target. \$\endgroup\$ Feb 8 '11 at 8:26
  • \$\begingroup\$ Hi Brainy, Jari, thanks for your comments. I would still like to see, if there are more options with user feedback available, therefore, I wish to keep this question open for a while. \$\endgroup\$ Feb 8 '11 at 12:19
  • \$\begingroup\$ @Jari - when discussing Math Library Optimization for OpenGL ES platform, what is included? I mean, if formula and data types are properly designed what else can be done to optimize the library for ES platform? (It might be elementary question, but I do not have answer for that.) \$\endgroup\$ Feb 8 '11 at 12:20

Eigen is a C++ header only math library that supports SSE, AltiVec and ARM Neon vectorisation.

  • \$\begingroup\$ +1 for great tip. Hi Simon, thanks for your great tip. I started using GLM (OpenGL Math Library), and it is pretty amazing. It contains everything from vector, matrix, quaternion math, SLERP interpotations, etc... so far, it offers more than I realy need, so I am happy with it for now. \$\endgroup\$ May 25 '11 at 13:22

Here are 2:

  1. Sony's vectormath
  2. Bullet's Linearmath
  • \$\begingroup\$ +1 for good tips. Hi Maik, thanks for your comments. In my opinion, the second might be useful especially when the game integrates Bullet Physics. My game is going to use Bullet Physics, but unfortunatelly, I have started using GLM, so I will try to stick to GLM. \$\endgroup\$ May 25 '11 at 13:26

I worked on adding Apple's GLKMath to the this test (actually forked this fork)

Here's the result on my 4 Generation iPod Touch:

Additions: 77624 milliseconds.
Multiplications: 227179 milliseconds.

Additions: 23935 milliseconds.
Multiplications: 80599 milliseconds.

Additions: 102390 milliseconds.
Multiplications: 161059 milliseconds.

Additions: 8526 milliseconds.
Multiplications: 21775 milliseconds.

Here's my code

I don't have an Android Device, but I'm curious how GLKMath will perform on Android.


This is an old question, but I came across a very recent article that addresses just this issue by taking into consideration performance, documentation, ease-of-use, etc...



Not the answer you're looking for? Browse other questions tagged .