View Full Version : Matrix API

06-08-2011, 09:25 PM
Not sure if there is a stand supported api for a matrix class, it would be appreciated if someone could recommend one. I'd assume the api would also include quaternion. Sorry if there is an obvious answer, I googled but didn't get any hits.

06-09-2011, 12:44 AM
There are several 3D math libraries out there.
What I personally use is GLM: http://glm.g-truc.net/

06-09-2011, 12:55 AM
This question is handled in the wiki:


But don't forget this library:


It (EDIT: sometimes) outperforms glm and is less cluttered with GL-specific stuff (i.e. you can also use it in a DirectX project).

Alfonse Reinheart
06-09-2011, 01:10 AM
i.e. you can also use it in a DirectX project

There's nothing stopping you from using GLM in a D3D project. It doesn't make any OpenGL API calls. Vectors and matrices are platform-agnostic.

06-09-2011, 01:21 AM
Well, you can and it even has some fast assembly matrix and vector code. Use depends on taste and benching.

I think it used to have some GL-specifics in an older version and I didn't bother to check.

06-09-2011, 01:23 AM
I don't want to start the flame war again whether tvmet or GLM is better, but...

As Alfonse said, you can use GLM with OpenGL, D3D or in whatever context you wish. It is a standalone math library. The only thing that makes GLM somewhat related to OpenGL is that it uses the same naming conventions and rules like those of GLSL thus it has kind of a standard interface. Also, if you work with OpenGL it feels more natural to work with GLM than any other math library thanks to the similar/matching conventions.

06-09-2011, 01:38 AM
Please no flame-war again. I don't have wiki-access, or I'd have added it a long time ago to the wiki. Only bench and real-life test will give a definite answer; sometimes it is good to have alternatives to choose from.

06-09-2011, 01:43 AM
ugluk, you should be able to create an account on the GL wiki.

06-10-2011, 10:16 AM
Anyone and everyone is able to contribute to the Wiki. You just need to create an account.

Alfonse Reinheart
06-10-2011, 02:00 PM
I don't have wiki-access, or I'd have added it a long time ago to the wiki.

I just added it for you.

06-10-2011, 06:23 PM
If you're so inclined, you could even use the D3DX stuff with OpenGL. OK, it's most definitely not portable, but if you're doing a project that has both OpenGL and D3D renderers, it's a viable option.

06-10-2011, 09:28 PM
Thanks for the help, I ended up using glm as I don't have to worry about compatibility with glsl. I was thinking about using directx but that would defeat the purpose entirely of using opengl :P.