majakthecoder
majakthecoder

Reputation: 177

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 vectors manipulations. I always had doubts about the performance of my math library, so I recently decided to search for some popular math library which is used by many game / graphics developers. I was surprised that I couldn't find anything.

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

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

I was surprised by these results, because my implementation of multiplying matrices is taken from wikipedia. I checked the code from glm and eigen and I found, that there is a lot of typedefs, assertions and other type checking, unnecessary code, which decrease performance a lot.

So, my question is: Do you know any FAST math library with nice API for gamedev / graphics purpose? I need functionality like: creating translation, rotation, projection, matrix * matrix, inverse, look at, matrix * vector, quaternions, etc...

Upvotes: 3

Views: 3572

Answers (1)

DevO
DevO

Reputation: 375

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

Are you sure that you have done all this benchmarks using higher compiler optimization ON ?

And not for example using Debug settings ?

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

Upvotes: 2

Related Questions