#151899 - Rajveer - Thu Mar 06, 2008 2:14 pm
How do I multiply matrices using the hardware? glLoadMatrix loads a matrix onto the current OpenGL stack right? So if I wanted to concatenate rotations using hardware during collisions and before rendering, how would I do this without messing with the OpenGL stacks?
#151900 - a128 - Thu Mar 06, 2008 2:30 pm
Matrix mtx= matrix1*matrix2 using the NDS hardware
Code: |
int32 matrix1[4*4];
int32 matrix2[4*4];
int32 mtx[4*4];
//matrix mult test
glMatrixMode(GL_MODELVIEW);
//matrix1
//Spalte 1
matrix1[0]=inttof32(1);
matrix1[4]=0;
matrix1[8]=0;
matrix1[12]=0;
matrix1[1]=0;
matrix1[5]=inttof32(1);
matrix1[9]=0;
matrix1[13]=0;
matrix1[2]=0;
matrix1[6]=0;
matrix1[10]=inttof32(1);
matrix1[14]=0;
matrix1[3]=0;
matrix1[7]=0;
matrix1[11]=0;
matrix1[15]=inttof32(1);
//matrix2
matrix2[0]=inttof32(7);
matrix2[4]=0;
matrix2[8]=0;
matrix2[12]=0;
matrix2[1]=0;
matrix2[5]=inttof32(10);
matrix2[9]=0;
matrix2[13]=0;
matrix2[2]=inttof32(23);
matrix2[6]=0;
matrix2[10]=inttof32(1111);
matrix2[14]=0;
matrix2[3]=0;
matrix2[7]=0;
matrix2[11]=0;
matrix2[15]=inttof32(-9);
glLoadMatrix4x4((m4x4*)&matrix1);
glMultMatrix4x4((m4x4*)&matrix2);
//mtx=matrix1*matrix2
glGetFixed(GL_GET_MATRIX_POSITION,(int32*)&mtx);
|
#151902 - Rajveer - Thu Mar 06, 2008 3:02 pm
Cool cheers for that, just wanted to make sure that people use the gl stacks too or if I should be doing it another way.
#151913 - Rajveer - Thu Mar 06, 2008 4:09 pm
Does the hardware matrix multiply perform normalisation and orthogonalization too? I've been rotating in all axes for a while but the model doesn't seem to skew/stretch or anything.
EDIT: Scratch that, didn't do it for long enough. Since, sqrtf32 uses hardware square root, is it pretty quick to perform?