Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: fix background

  1. #1
    Guest

    fix background

    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

  2. #2
    Member Regular Contributor
    Join Date
    Jul 2001
    Posts
    409

    Re: fix background

    Just draw the axis _before_ you do the rotations/translations. Remember, rotations/translations apply only to objects drawn thereafter.

    Morglum

  3. #3
    Guest

    Re: fix background

    I tried but it's didn't visible, how come?

  4. #4
    Member Regular Contributor
    Join Date
    Jul 2001
    Posts
    409

    Re: fix background

    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

    }

  5. #5
    Member Regular Contributor
    Join Date
    Jan 2002
    Posts
    296

    Re: fix background

    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();

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •