View Full Version : how to use glutGetModifiers

09-19-2004, 09:25 AM
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

09-20-2004, 10:04 PM
If you look at the glut documentation you will notice that the function returns a bitmask, so you should use something like:

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"