Fast, portable, C ++ math library for matrix and vector manipulations

I have my own game engine which is written in opengl and C ++. I also have my own math library for matrix and vector manipulation. I've always had doubts about the performance of my math library, so I recently decided to find some popular math library that is used by many game / graphics developers. I was surprised I didn't find anything.

People on stackoverflow suggested the GLM and Eigen libraries in similar posts, so I did some performance tests. I have multiplied 1,000,000 times two 4x4 matrices and here are the results:

GLM: 4.23 seconds
Eigen: 12.57 seconds
My library: 0.25 seconds

      

I was surprised with these results because my implementation of multiplying matrices is from wikipedia. I checked the code from glm and eigen, and I found that there are many typedefs, assertions and other types of validation, unnecessary code that dramatically decreases performance.

So my question is: Do you know any FAST math library with a good API for gamedev / graphics target? I need functionality like: create translation, rotation, projection, matrix * matrices, inverse, view, matrix * vector, quaternions, etc.

+3


source to share


1 answer


I checked the code from glm and eigen and I found that there are a lot of typedefs, assertions and other type checking, unnecessary code, which dramatically decreases performance.

Are you sure you did all of these tests using higher compiler optimizations?



And don't use Debug settings, for example?

Another alternative would also be Google's MathFu.
http://google.github.io/mathfu/

+2


source







All Articles