Thread: (free)glut and keyboard repeat rates

  1. #1
    Registered User
    Join Date
    Feb 2010

    (free)glut and keyboard repeat rates


    I'm hoping someone can point me in the right direction since I'm a bit stuck.

    I'm playing around with Nvidias PhysX engine, OpenGL and freeglut.

    I wanted to implement nice and smooth camera motions, which required different handling of keyboard events, I moved from the single keyboard callback, to the keyboard callback along with keyboardUp callback as in this thread here :

    GLUT Keyboard Reaction Help

    The code I'm using is exactly the same as in the above thread, however, where most people ask "How do I disable keyboard delays??" mine is "How do I get it back?"

    To explain:
    This type of handling is perfect for camera controls, but, when I bind a key to a function that creates a new actor in the simulation, the function gets called at least 10 times per key press, no matter how short.

    How can I keep the current functionality for camera controls, but make the actor creation functions be called once per key press?

    If anyone could point me in the right direction I'd greatly appreciate it, I know it can be done, any 3d game out there has this implemented, I just don't know how....

    Thank you


  2. #2
    Registered User
    Join Date
    Feb 2010
    I might have found a solution if anyone else comes across a similar issue.

    The solution, although not perfect yet, works on a timer.

    Basically when a key gets pressed, a flag is tripped and the trip is timed for some amount of time, after the time passes, the flag is reset again. The flag naturally allows the execution of the functions.

    My only problem is at some specific instance is does not get picked up, but I'll work it out. I think it has to do with when the flag is triped, just have to find the right spot.

    I don't know how effective of efficient this is yet, comments are welcome.



Popular pages Recent additions subscribe to a feed