PDA

View Full Version : lib of matrices and vectors



Nonozor
03-04-2010, 04:22 PM
Hello!

looking at the code of other people, I think that lot of them implements their own matrices and vectors structures and operations to avoid using an external lib.

My question is "What are the pros and cons of using a lib of matrices and vectors in an OpenGL program?"

My pros:
- well implemented
- gain of time
- if I implement it, it will be the same because there are not many different ways to do a translation, a rotation, etc

My cons:
- it make an external dependencie and it is not long to implement.

What do you think about it?
I am a beginner and I am really looking forward to your answers!!!

Dark Photon
03-04-2010, 05:57 PM
What do you think about it?
Other pros for rolling your own:

- You have a concrete understanding of how it works.
- You can add to it or change the interface as desired
- You can optimize it at-will
- It follows your sense for what a reasonable implementation should be.

More on the latter. External libraries run the gamut between a small set of functions operating directly on float[N] buffers, to super-complex massively-templated extravaganzas that take some mind-bending to even figure out how to use, much less debug with, decipher the obtuse compilation errors, or (gasp) extend them.

Personally I prefer a very basic single class per vector type implementation, providing element access via .x/.y/etc. or [0]/[1]/etc.

You're gonna be using this all over your code, so you want it to result in code that meets your standards of readable and maintainable.

So take a couple libs for a spin. If you can't figure out how to use it fairly quickly, just move on. Get a feel for what you want in a lib. Maybe somebody's already written exactly what you desire!

Nonozor
03-13-2010, 04:49 AM
OK, thanks.


You're gonna be using this all over your code, so you want it to result in code that meets your standards of readable and maintainable.

exactly! I have to start my program soon and it would be difficult to change the math after having spreading it all over my code, so I'd like to find a good one know, or to develop one by myself (but I don't have much time).

What do you think of CML (Configurable Math Library)???
Of OpenGL Mathematics (GLM)???

Dark Photon
03-15-2010, 07:09 PM
Not much. Have barely tried the latter. We have our own internal lib. Try them and let us know.