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

Thread: how to use glutGetModifiers

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2004
    Posts
    2

    how to use glutGetModifiers

    below is my code for my game which is my assignment however i wish to make a coding for the character to walk forward when press w and Shift w for running and i use the code below however no matter what i do it will only walk and not run did i use the functions correctly?

    if (glutGetModifiers() == GLUT_ACTIVE_SHIFT)
    RunForward(); //turn forward
    else
    WalkForward();

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    Kristianstad,Skåne,Sweden
    Posts
    1,595

    Re: how to use glutGetModifiers

    If you look at the glut documentation you will notice that the function returns a bitmask, so you should use something like:

    Code :
      if( glutGetModifiers() & GLUT_ACTIVE_SHIFT))
    Have you tried to find the problem yourself ? does the glutGetModifiers() function always return GLUT_ACTIVE_SHIFT or what ? are you sure that your own code works (the run vs. the walk code).

    And notice:
    "This routine may only be called while a keyboard, special, or mouse callback is being handled"

    Mikael

Posting Permissions

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