strange behaviour in glut

This is a discussion on strange behaviour in glut within the Game Programming forums, part of the General Programming Boards category; like this, when i press a key, the following function will be called: //--------------------------------------------- static void move(int dir) //dir means ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    6

    strange behaviour in glut

    like this, when i press a key, the following function will be called:
    //---------------------------------------------
    static void move(int dir) //dir means direction
    {
    int i;
    for(i=0; i<30; i++){
    //recalculate some angle value
    angle=(angle+degree)%360;
    glutPostRedisplay();
    }
    }
    //------------------------------------------------
    angle is a static global variable, assum degree is set to 1.
    the strange behaviour i can't understand is only the last angle value will be pass to display() that is 30! the value 1~29 are all ignored! Why this happen?
    and I also found many variable-pass problems in glut. I really wonder if the glut is a good choice for opengl programming??

  2. #2
    Visionary Philosopher Sayeh's Avatar
    Join Date
    Aug 2002
    Posts
    212
    Next time, use the code tags--

    Code:
    static void move(int dir)                      //dir means direction
       {
       int i;
       for(i=0; i<30; i++)
          {
          angle=(angle+degree)%360;      //recalculate some angle value
          glutPostRedisplay();
          };
       }
    Well, first of all, your loop only runs 0-29 (30 values). Second, 'i' isn't used for anything else. Thirdly, no function named 'display()' is shown.

    Too many pieces missing. The reason you are seeing this missing 'display()' show anything at all is probably because you are simply falling through to it. Your loop is never executed once i = 30.
    It is not the spoon that bends, it is you who bends around the spoon.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. strange fopen behaviour
    By AngKar in forum C Programming
    Replies: 2
    Last Post: 01-09-2006, 05:58 AM
  2. strange behaviour of sscanf
    By BeBu in forum C Programming
    Replies: 7
    Last Post: 12-17-2004, 09:12 AM
  3. GetClientRect strange behaviour
    By btq in forum Windows Programming
    Replies: 2
    Last Post: 10-02-2002, 02:13 PM
  4. Strange behaviour
    By PrivatePanic in forum Windows Programming
    Replies: 11
    Last Post: 07-23-2002, 12:54 AM
  5. strange behaviour by rhide
    By ustuzou in forum C++ Programming
    Replies: 0
    Last Post: 03-17-2002, 10:31 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21