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

Thread: User input in OpenGL

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2012
    Posts
    13

    User input in OpenGL

    I am wondering if OpenGL allows you to get user input from the terminal in traditional sense (i.e. std::cin>>). My program requires user input on several occasions in its execution, and I would like to know what is the most commonly used means for getting ascii character user input in OpenGL.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,792
    OpenGL has nothing to do with user input. It neither inhibits nor aids your ability to use the command line, or any other form of user interface.

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2012
    Posts
    13
    The issue that I am facing in that the user input in my program prevents the graphics from displaying. The first part of my program draws a single line. When I comment out the first user input (std::cin) and everything beyond, the line displays normally. Otherwise, all I get is a dark window. Do you have any explanation?

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    947
    Yes, reading from std:cin blocks your application (at least the current thread) until the requested user input is available. You either want to move your rendering to another thread or use some sort of asynchronous input mechanism like GetAsyncKeyState on Windows.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

  5. #5
    Junior Member Newbie
    Join Date
    Jun 2012
    Posts
    13
    Thank you for clearing that up. On that note, I am wondering what method I might use to move the rendering to another thread or, alternatively, what asynchronous input mechanism is used on Linux.

  6. #6
    Member Regular Contributor Rosario Leonardi's Avatar
    Join Date
    Aug 2008
    Location
    Italy
    Posts
    352
    You can simply embed you application in any gui? WxWidget is too mainstream?
    Then you have dialog, slider, text field.
    Otherwise if you need a really easy and simple GUI you can use anttweakbar. link -> http://www.antisphere.com/Wiki/tools:anttweakbar
    ~ ~ I tell you, realtime 3D is made of blood, sweat and screams! ~ ~

  7. #7
    Junior Member Newbie
    Join Date
    Jun 2012
    Posts
    13
    Hmmmm... I guess wxWidgets would work. The program already uses an X11 window for rendering, so it may be better to simply add GUI to the existing window. Does GLUT have any input options that might work?

Posting Permissions

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