# glrotatef and my matrix::rotate

hi all,

i want to obtain a mousellok effect.

using fixed opengl function, this can be made doing

glRotate(angley,0,1,0);
glRotate(anglex,1,0,0);

using my matrix class, the result is not as above:

mat4 cammtx;
cammtx.rotate(angley,0,1,0);
cammtx.rotate(anglex,1,0,0);

because camera not still holding the y axis

why can i achieve the same glRotate behaviour with my matrix::rotate implementation?

here is my rotate function (input vector is not normalized, i know, but i pass only unit vectors)

void rotate(float* mr,float* m,float angle,float x,float y,float z)
{
float a=angle*PI_OVER_180;
float m2 = {0};

``````    float c=cos(a);
float s=sin(a);

float  xx=x*x,
yy=y*y,
zz=z*z;

m2 = xx+(1.0f-xx)*c;
m2 = (1.0f-c)*x*y-s*z;
m2 = (1.0f-c)*x*z+s*y;
m2 = 0.0f;

m2 = (1.0f-c)*y*x+s*z;
m2 = yy+(1.0f-yy)*c;
m2 = (1.0f-c)*y*z-s*x;
m2 = 0.0f;

m2 = (1.0f-c)*z*x-s*y;
m2 = (1.0f-c)*z*y+s*x;
m2 = zz+(1.0f-zz)*c;
m2 = 0.0f;

m2 = 0;
m2 = 0;
m2 = 0;
m2 = 1.0f;

multiply(mr,m2,m);
}
``````

float* multiply(float* c,float* aa,float* bb)
{
for(int i = 0; i < 4; i++)
{
c[i*4] = bb[i*4] * aa + bb[i*4+1] * aa + bb[i*4+2] * aa + bb[i*4+3] * aa;
c[i*4+1] = bb[i*4] * aa + bb[i*4+1] * aa + bb[i*4+2] * aa + bb[i*4+3] * aa;
c[i*4+2] = bb[i*4] * aa + bb[i*4+1] * aa + bb[i*4+2] * aa + bb[i*4+3] * aa;
c[i*4+3] = bb[i*4] * aa + bb[i*4+1] * aa + bb[i*4+2] * aa + bb[i*4+3] * aa;
}
return c;
}