PDA

View Full Version : OpenGL Mathematics Libraries



Avithohol
11-03-2010, 09:53 AM
Hello All

Just would like to start a discussion about OpenGL Mathematics Libraries

Until now i worked with Opengl 2.0
and have implemented my own little and simple math library:
cVec3, cMatrix, cQuaternion


As i dig myself into the Opengl 3.0+ and reading tutorials,
i do see people started to use third party math libraries.

I have also started to think about to switch to one.
Why ? My project grows and might need more professional math later.



The only thing that bothers me that all these libraries use templates.
I myself maybe a performance freak, but i think its a bit against the speed.
My math lib is pure GLfloat and inline functions.
Could a template library compete with the previous ?

Despite of that i am thinking about to switch to GLM.
Anybody has any insight which is the ultimate
OpenGL Mathematics Library from performance point of view ?


Have a nice day to you all !

Groovounet
11-03-2010, 11:07 AM
Hi,

Most template library speed impact is the compile time... which is a significant issue actually.

On the regard of program speed, some people would say it's quite good comparing to an approach using vitual functions because vitual functions can't be inlined. I think it's more or less true as some template based design can involve a significant large executable which impacts the CPU cache and reduce performance.

GLM is not going to involve larger executable than your own math library but it is not a library design so bring the highest performances. Following the 20-80 rules, GLM is a convenient library that is appropriate to use across 80% of the code which impact 20% of the performance. For the 20% of the code that impact 80% of the performance, some hand written code & optimizations could be necessary to reach best performance.

aqnuep
11-03-2010, 12:30 PM
I can also recommend GLM. I think that's one of the best if not the best OpenGL math library out there. The best thing in it is that it is completely made with OpenGL terminology in mind.

Its performance is as good as it should. Thanks to pure inline methods and header-only design makes it piece-of-cake for the compiler to optimize it. However, of course, the large headers have their own compilation time requirements but I think it worths for the benefits of GLM. Actually I use it for all my OpenGL projects for quite some time.

Obviously, as Groovounet mentioned, if you have some computationally expensive algorithms, you could write your own routines for it using SSE, OpenMP or other technologies to get optimum performance but generally going with pure GLM should be enough.

Avithohol
08-15-2011, 04:54 AM
Thank You all for the answers !

V-man
08-19-2011, 09:14 AM
You can use my glhlib if you want. Certain functions have SSE versions. For example, when you need to transform large number of vertices from one space to another.
There are no templates. These are just "C" functions.