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: Code for getting text input in OpenGL

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2005
    Location
    Malaysia
    Posts
    2

    Code for getting text input in OpenGL

    Is there a code for getting text input from users in OpenGL?

    1.I'm trying to get the user to input their text
    2.My program responds and chose a texture based on the text (texture name) that they chose.
    3.Renders it

    I know how to do textures, but i didn't know how to display the message and get user the user's text input. Plz help.

  2. #2
    Junior Member Regular Contributor
    Join Date
    Aug 2004
    Location
    Angers, France
    Posts
    248

    Re: Code for getting text input in OpenGL

    You can check NeHe's tutos about displaying text in OpenGL window, there is many way...

    NeHe webpage
    The .Product will make you .Believe

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Aug 2001
    Location
    Italy
    Posts
    628

    Re: Code for getting text input in OpenGL

    Originally posted by PhoenixByte:
    Is there a code for getting text input from users in OpenGL?
    Getting input is the tricky part.
    First thing, you could try using win32 console control functions (this is ugly but it could be useful until you have the real thing running).
    GetStdHandle, AllocConsole and FreeConsole are some functions you will need. Also check ReadConsoleInput and stuff like that.
    For each loop, you could check for console input, parse it and send it to the render loop.
    Getting text input without the ugly console is actually pretty easy. The not-so-easy thing is managing it right.
    Win32 sends a WM_CHAR message every time a character is generated. This is good because
    1- It also handles ALT+N (useful to generate ascii glyphs like } we all love or ~).
    2- It handles repetition rate nicely (so users will find the repetition rate it's just like notepad or their favourite editor).
    3- Other minort things I don't remember.

    Some things however are nasty.
    For example, while it gives you characters, some chars does not produce glyphs. Backspace is something evil. "up" and "down" is worse. "left" and "right" will make you run out screaming but you may find you don't need so evolved functionalities.

Posting Permissions

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