What are the pro’s and con’s of, for example, using a D3DXVECTOR3 (a directX triple float) as opposed to using three floats in a function call.
so
Scale(D3DXVECTOR3(1, 1, 1));
as opposed to
Scale(1, 1, 1);
Is it better to use the second and only convert to a D3DXVECTOR3 when you need to use a library specific maths functions?
I also notice that many libraries have their own types for floats and doubles and so on. thoughts?
One big reason to have APIs accept structures of floats instead of the floats themselves is readability. In any application using 3D graphics, you’re certainly going to have to work with lots of vectors. This is way more readable and maintainable:
than this:
In other words, it allows for self-documenting code. Not to mention taking less time to type when you need to declare a vector (one
D3DXVECTORas opposed to three separatefloats).That being said, typically a 3D graphics library/framework would define their own vector types and floating point types for portability across different platforms and configurations. One may simply define these types as follows: