PDA

View Full Version : fix background



05-01-2002, 09:29 PM
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

Morglum
05-01-2002, 10:38 PM
Just draw the axis _before_ you do the rotations/translations. Remember, rotations/translations apply only to objects drawn thereafter.

Morglum

05-02-2002, 02:02 PM
I tried but it's didn't visible, how come?

Morglum
05-03-2002, 07:54 AM
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

}

Miguel_dup1
05-03-2002, 08:26 AM
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();