This is not a math question but a performance question:

I have a transformation matrix M.

I have a static number of transformation matrices - say N1, N2, …Nn. These remain static, too. They’re defined once.

Based on specific info I need to multiply M with Nx. And: I need the resulting matrix ® for further “manual” number crunching. I’ve implemented this in two ways - my question to you is, which one is faster/better?

way 1 - do it via OpenGL:

for example N1 is defined/initialized as a DisplayList (some rotatef, etc.).

glLoadMatrix(M);
// select theDisplayList based on some
// specific data, then call this list
glCallList(theDisplayList);

glGetDoublev(GL_MODELVIEW_MATRIX, R);

No I have R and can play with it.

OR

N1 is defined in my own MatrixTypeDef, I do everything “internally”, I multiply M with N1 by my own MatrixMultiplicationFunction, I get R and the only thing OpenGL has to say is:

glLoadMatrix®

I think the 2nd one is cleaner: more Model-View-Controller like. But the 2nd one could be faster, eventually. Is this correct? Is it relevant? Is it worth it, if the application is not meant to be highly portable?

There are four reasons why you shouldn’t use OpenGL as a math library.

1: It isn’t a math library.
2: It involves a glGet* command, which might stall the rendering pipeline, and might cause a performance hit.
3: The code becomes less easy to read, follow and uderstand. Even though you know what it does, someone else might not. It’s just a “dirty coding style”.
4: You can do much better yourself, with your own code. That is, the total time needed to obtain the resulting matrix.

Even though OpenGL might perform the actual matrix multiplication faster than you can, it involves much more than just multiplying two matrices. If you do it on your own, you don’t have to stall the rendering pipeline either.

I agree with the above, it is worth doing this in OpenGL only if you intend to use the matrix to transform vertices in hardware and don’t need to read it back, otherwise use your own math. Using glGet for state that’s deep in the pipeline is a bad thing.