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: Improving keyboard response

  1. #1
    Junior Member Newbie
    Join Date
    May 2010
    Posts
    2

    Improving keyboard response

    I'm fairly new to the OpenGL scene, so my problem may be worded improperly with incorrect terms. If so, I apologise in advance.

    I am doing my coding solely on a Ubuntu system, so to make the code more portable, I am relying on GLUT to do the heavy lifting with windows and user input. That said, let me describe my problem:

    I am attempting to develop a 2D board game where the keyboards arrow keys can manipulate a "player" piece on a grid of unoccupied squares. To start, I implemented the board system with integers where the players piece would only be in a single given square at any time. The glutSpecialFunc() performs this task perfectly, but as the game progressed, I wanted to make the players piece more free-moving on the board environment. To do this, I altered the player piece coordinate system to be floating-point, instead of integer-based, and the glutSpecialFunc() instead incremented it's coordinates by fractions of numbers.

    Ok, all this works so far, but the behaviour of the keyboard functions is a little, for lack of a better word, clunky. When i want to move a small distance, I hit an arrow key. When I want to move a large distance I hold the arrow key, but my problem lies in the response here. My player piece moves a single unit, hesitates for ~1-2 beats then shoots off at a more constant/steady speed across the board.

    I know this behaviour is standard for keyboards in the application of, say, a word processor, but I was wondering if there is any way to alter the default reaction of the keyboard?

    Any help would be greatly appreciated, and although I would like to resolve this issue within GLUT, I also understand this may be beyond the scope that GLUT was intended.

    Thank you all in advance,
    Spoon

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: Improving keyboard response

    Use GLFW. Way better than glut for a game. http://www.glfw.org/
    apt-get install libglfw-dev libglfw2

    Anyway, with GLUT you have to do this :
    glutSetIgnoreKeyRepeat(true);
    And watch for both key down and key up (with glut*UpFunc) events.

  3. #3
    Junior Member Newbie
    Join Date
    May 2010
    Posts
    2

    Re: Improving keyboard response

    Thank you very much, will begin incorporating GLFW asap.

Posting Permissions

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