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 3 of 3

Thread: Basic Animation

  1. #1
    Guest

    Basic Animation

    Hi,

    I'm using Glut and....

    I'm trying to do some basic animation:
    I have a cube and I would like it to
    move smoothly upwards,
    then once there move right;
    then move back down to the original height;
    finally it should move back to it's starting position.


    X----------X
    | |
    | |
    X----------X

    I must be really thick as I cannot see how to use the idlefunction to do
    this, all I manage is to get it to move upwards slowly to a certain point
    then I cannot get to to come down again, as I'm fighting against the
    idlefunction.....

    ideas??


    thanks

    Greg

  2. #2
    Junior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    State College, PA
    Posts
    204

    Re: Basic Animation

    The idea that immediately comes to mind is a case statement:
    Code :
    switch(direction){
    	case up: translate up some more; break;
    	case left: translate left some more; break;
    	case down: translate down some more; break;
    	case right: translate right some more; break;
    }
    Put it in your idle function, and have a counter that switches your direction at the correct points.

    Chris

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    3,115

    Re: Basic Animation

    ... and after that, in the idle-function, you place glutPostRedisplay() to tell GLUT that you want to redraw the screen.

Posting Permissions

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