basically what ive got going is some transformations using my own functions, ive got them working fine still using glMultMatrix but im not allowed to use that for this.
im trying to make my own matrix multiplication function and im getting stuck somewhere.
the matricies are all one dimensional arrays and im going around in loops.
im multiplying 2 4x4 matricies (so a array with 16 elements)
void myMulti(GLfloat (&gMat)[16]) //givenmatrix
{
glGetFloatv(GL_MODELVIEW_MATRIX, cMat); //current active matrix (model view in this case currently loaded with identity matrix)
GLfloat fMat[16]={0}; //finalmatrix
fMat[0]=cMat[0]*gMat[0]+cMat[0]*gMat[1]+cMat[0]*gMat[2]+cMat[0]*gMat[3];
fMat[1]=cMat[1]*gMat[0]+cMat[1]*gMat[1]+cMat[1]*gMat[2]+cMat[1]*gMat[3];
fMat[2]=cMat[2]*gMat[0]+cMat[2]*gMat[1]+cMat[2]*gMat[2]+cMat[2]*gMat[3];
fMat[3]=cMat[3]*gMat[0]+cMat[3]*gMat[1]+cMat[3]*gMat[2]+cMat[3]*gMat[3];
fMat[4]=cMat[4]*gMat[4]+cMat[4]*gMat[5]+cMat[4]*gMat[6]+cMat[4]*gMat[7];
fMat[5]=cMat[5]*gMat[4]+cMat[5]*gMat[5]+cMat[5]*gMat[6]+cMat[5]*gMat[7];
fMat[6]=cMat[6]*gMat[4]+cMat[6]*gMat[5]+cMat[6]*gMat[6]+cMat[6]*gMat[7];
fMat[7]=cMat[7]*gMat[4]+cMat[7]*gMat[5]+cMat[7]*gMat[6]+cMat[7]*gMat[7];
fMat[8]=cMat[8]*gMat[8]+cMat[8]*gMat[9]+cMat[8]*gMat[10]+cMat[8]*gMat[11];
fMat[9]=cMat[9]*gMat[8]+cMat[9]*gMat[9]+cMat[9]*gMat[10]+cMat[9]*gMat[11];
fMat[10]=cMat[10]*gMat[8]+cMat[10]*gMat[9]+cMat[10]*gMat[10]+cMat[10]*gMat[11];
fMat[11]=cMat[11]*gMat[8]+cMat[11]*gMat[9]+cMat[11]*gMat[10]+cMat[11]*gMat[11];
fMat[12]=cMat[12]*gMat[12]+cMat[12]*gMat[13]+cMat[12]*gMat[14]+cMat[12]*gMat[15];
fMat[13]=cMat[13]*gMat[12]+cMat[13]*gMat[13]+cMat[13]*gMat[14]+cMat[13]*gMat[15];
fMat[14]=cMat[14]*gMat[12]+cMat[14]*gMat[13]+cMat[14]*gMat[14]+cMat[14]*gMat[15];
fMat[15]=cMat[15]*gMat[12]+cMat[15]*gMat[13]+cMat[15]*gMat[14]+cMat[15]*gMat[15];
glLoadMatrixf(fMat);
}
i know theres a better way to do this, thre has to be but i couldnt work out a way to do it with for loops cause of it being a 1d array.
also i think i may have something wrong with my matrix multiplication there also, but if i can get it into some loops, that will most likley streamline the function and solve those problems also. ty for help in advance.