PDA

View Full Version : getting Matrix after glMatrixMult



mcruz
11-27-2001, 10:03 AM
I want to multiply two matrices and get the resulting matrix. For example for testing I tried to do this:

GLdouble mat[16];
GLdouble m[16] = 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

glPushMatrix();
glMultMatrixd(m);
glLoadIdentity();
glPopMatrix();

glGetDoublev
(GL_MODELVIEW_MATRIX,mat);

I want mat to return a matrix with zeros but it returns something different. How would I get the matrix after glMultMatrixd(m)?

Thanks,
Marc

Coconut
11-27-2001, 10:14 AM
Originally posted by mcruz:
I want to multiply two matrices and get the resulting matrix. For example for testing I tried to do this:

GLdouble mat[16];
GLdouble m[16] = 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

glPushMatrix();
glMultMatrixd(m);
glLoadIdentity();
glPopMatrix();

glGetDoublev
(GL_MODELVIEW_MATRIX,mat);

I want mat to return a matrix with zeros but it returns something different. How would I get the matrix after glMultMatrixd(m)?

Thanks,
Marc

I guess you don't even know how to use glPopMatrix, glPushMatrix etc.
Your code can be like this:


GLdouble mat[16];
GLdouble m[16] = 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

glPushMatrix();
glMultMatrixd(m);
glGetDoublev(GL_MODELVIEW_MATRIX,mat);
glPopMatrix();

mat should be a zero matrix.

It is also not recommended to use GL to do your math due to performance reason.