addition of transformation matrix

i have a transformed modelview matrix stored in a float array. now i want to add this matrix to the current matrix (the current matrix is also in an array).
is this possible?

thanks h.stony

Yes though not directly - there isn’t a glAddMatrix function.

pseudo code:

 

float mymat[16];
...
initialize mymat
...
float mat[16];
mat = glGetFloatv( GL_MODELVIEW_MATRIX );
for( i=0;i<16;i++ )
    mat[i] += mymat[i];
glMatrixMode( GL_MODELVIEW );
glLoadMatrixf( mat );

 

But… why would you want to add a matrix to another?

Combining the effects of the matrices is a matter of multiplying matrices (use glMultMatrix).
That’s how OGL handles its rotates/translates/scales.

yes. glMultMatrix was my first idea. but the result was really strange. i know that a addition beetween the matrices is senseless. i try glMultMatrix a second time.

-pseudocode

  float mymat[16];
...
initialize mymat
...
gMultMatrix(mymat);
glMatrixMode( GL_MODELVIEW ); // i am already in modelview mode. but without it doesn't work
glLoadMatrixf( mat );

thanks

obtain the modelview matrix add the 2 together and load the resulting matrix