Hi there is there anyway to multiply your current matrix with the one on the stack?
I’m testing out some object oriented coding with multiple cameras
So I have created a 3D world system
every object in it have global positions but local rotations
but to rotate every object locally before i draw them i have to first load an identity matrix then rotate then move it and then
somehow apply it with the camera-matrix that was pushed on the stack. I guess i could make every object store a local rotation matrix and multiply it with the camera-matrix or i hoped that opengl was smart enought to make a built in “multiply current matrix with top stacked matrix operation”, because this probly would be super efficiant rather than storing matrixes some other place.
so is there one?
glPushMatrix(); //push camera matrix on stack
glLoadIdentity(); //creation of object matrix starts here
glRotatef(rx,1.0f,0.0f,0.0f); //apply local rotations
glRotatef(ry,0.0f,1.0f,0.0f);
glRotatef(rz,0.0f,0.0f,1.0f);
//space for my hoped matrix operation //merge camera matrix with object matrix
glTranslatef(px,py,pz); //apply global position
glBegin(GL_LINES);
glColor4f(1.0f,0.0f,0.0f,alpha);
glVertex4f(+scale,0.0f,0.0f,alpha);
glVertex4f(0.0f,0.0f,0.0f,alpha);
glColor4f(0.0f,1.0f,0.0f,alpha);
glVertex4f(0.0f,+scale,0.0f,alpha);
glVertex4f(0.0f,0.0f,0.0f,alpha);
glColor4f(0.0f,0.0f,1.0f,alpha);
glVertex4f(0.0f,0.0f,+scale,alpha);
glVertex4f(0.0f,0.0f,0.0f,alpha);
glEnd();
glPopMatrix(); //pop camera matrix on the stack