Matrix multiplication

I’m dealing with a kind of 3D-fractal based program which heavily uses matrix multiplication. What’s the faster way: build my own matrices and multiplication-routines, or use the glLoadMatrix and glMultMatrix?


That depends on what you’re ultimately trying to do. If you’re using these matrices to draw things using OpenGL, then using the OpenGL functions could be a good idea - they could possibly be accelerated, if not in hardware then in SSE or 3DNow!.

However, if your plan is to use OpenGL functions then read the matrix back, then I’d suggest that you stick to your own matrix code, and save the function calls and the data copies involved. You could probably optimise matrix multiplication yourself pretty well.


I agree with the above. If you find you need the matrix yourself AND your inner loops do a lot of matrix multiplication, you can use Intel’s MMX compiler and library (assuming you’re WIntel). It uses the SIMD (single instruction multiple data) architecture of the PIII and PIV.