I try to draw the coordinate system, x,y,z axis on the screen and want to freeze that there, and when I rotate an object like a square(vertex(1.0)…) the coordinate system stay the same, just the square get rotate,translate and scale? I try but it’s rotate the axis(make by vertex3f) also… Any one got any idea, how to do that ? thx
Just draw the axis before you do the rotations/translations. Remember, rotations/translations apply only to objects drawn thereafter.
Morglum
I tried but it’s didn’t visible, how come?
Maybe you’ve drawn the axis too early… Your rendering code should look like :
void display_scene ()
{
glClear (… //and other pre-render stuff
glLoadIdentity (); // This must be done before drawing anything - even the axis
draw_the_axis ();
glTranslatef(… //translation applied to the object
glRotatef(… // rotation applied to the object
draw_the_object ();
swap_buffers (); // or any other post-render stuff
}
Yeah, the way Morglum said would work… But you could also call glLoadIdentity() right before drawing your axis…
so
glLoadIdentity();
rotate();
.
.
draw stuff
glLoadIdentity()
darwAxis();