Results 1 to 7 of 7

Thread: Better-than-GLUT keyboard/mouse handling

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2009
    Location
    United States
    Posts
    2

    Better-than-GLUT keyboard/mouse handling

    Hey everyone, first post so go easy on me

    I am learning OpenGL to do research at my university and am using GLUT & OpenGL. I'm looking for something that handles keyboard and mouse input better (you know... event polling and such so that you can move multiple directions at once and have better mouse click interation).

    I guess I'm looking for a way to read keyboard and mouse input that is as good as game engines I've used (SDL, C4, etc.).

    And since I want to be working down-and-dirty with OpenGL, it needs to be something that can work alongside or under OpenGL, not something that has some OpenGL bindings built in and such.

    Thanks!
    Jeff

  2. #2
    Senior Member Regular Contributor
    Join Date
    Dec 2008
    Location
    USA
    Posts
    134

    Re: Better-than-GLUT keyboard/mouse handling

    You could use SDL, especially as you seem familiar with it already. GLFW is a relatively small library that does these things, as well as a bunch of libraries on this page.

  3. #3
    Senior Member Regular Contributor
    Join Date
    Jan 2005
    Location
    Stockholm, Sweden
    Posts
    164

    Re: Better-than-GLUT keyboard/mouse handling

    I would recommend SDL because it offers a lot of freedom over simpler libraries, such as GLUT, GLFW, etc. For example, it does not use callback functions, that force you into doing things in a certain order, but rather allows you to make calls from anywhere. Also, the user-interaction part of SDL is particularly intuitive to use.

    I have been using SDL ever since I discovered it, and I have never looked back!

    Good luck!

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

    Re: Better-than-GLUT keyboard/mouse handling

    thinks: beg to differ, GLFW is very easy, and most of the callbacks functions are optionnal as they have a direct function counterpart. Personnaly, I found it much simpler than SDL to integrate with OpenGL. And the documentation is really good. Only drawback for games, its does not do sounds.

    As said above, if you already have experience with SDL, you can stick with it

  5. #5
    Junior Member Newbie
    Join Date
    Oct 2009
    Location
    United States
    Posts
    2

    Re: Better-than-GLUT keyboard/mouse handling

    Thanks for all of your replies so far.

    I've only ever done 2D stuff with SDL but it sounds like that's a good option.

    Could I have OpenGL/GLUT be the "main" thing running in my program and *just* use the input functionality of SDL or GLFW, does anyone know? My ideal situation is that I can use GLUT to set up an OpenGL rendering window and everything and then have only keyboard/mouse event polling running from whatever other library I use. I'd just do DirectInput, but I switched to Mac

  6. #6
    Senior Member Regular Contributor
    Join Date
    Jan 2005
    Location
    Stockholm, Sweden
    Posts
    164

    Re: Better-than-GLUT keyboard/mouse handling

    thinks: beg to differ, GLFW is very easy, and most of the callbacks functions are optional as they have a direct function counterpart. Personally, I found it much simpler than SDL to integrate with OpenGL. And the documentation is really good. Only drawback for games, its does not do sounds.
    No doubt GLFW is simpler, and it is what I was using before switching to SDL. However, I have found the small extra time invested in SDL very worth my while. Also, is GLFW still being developed? I know that SDL will be adding (if they haven't already) support for multiple windows, for instance.

    Anyway, I'm quite happy to disagree on this. Most important is to be "comfortable" with the choice in the end.

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

    Re: Better-than-GLUT keyboard/mouse handling

    Quote Originally Posted by Jeffrey Cook
    I've only ever done 2D stuff with SDL but it sounds like that's a good option.
    Yes it is, indeed.

    Could I have OpenGL/GLUT be the "main" thing running in my program and *just* use the input functionality of SDL or GLFW, does anyone know?
    You are wrong on one important point : you want to use OpenGL, but apparently glut sounds like it is not a good option for you.
    So either SDL+OpenGL, or GLFW+OpenGL (later I found simpler to start with, but YMMV).

    And it is very simple. Shamelessly taken from the official user documentation http://glfw.sourceforge.net/documentation.html :
    Code :
    #include <GL/glfw.h>
    int main( void )
    {
    int running = GL_TRUE;
    // Initialize GLFW
    glfwInit();
    // Open an OpenGL window
    if( !glfwOpenWindow( 300,300, 0,0,0,0,0,0, GLFW_WINDOW ) )
    {
    glfwTerminate();
    return 0;
    }
    // Main loopGLFW Users Guide API version 2.6 Page 5/40
    while( running )
    {
    // OpenGL rendering goes here...
    glClear( GL_COLOR_BUFFER_BIT );
    // Swap front and back rendering buffers
    glfwSwapBuffers();
    // Check if ESC key was pressed or window was closed
    running = !glfwGetKey( GLFW_KEY_ESC ) &amp;&amp;
    glfwGetWindowParam( GLFW_OPENED );
    }
    // Close window and terminate GLFW
    glfwTerminate();
    // Exit program
    return 0;
    }


Similar Threads

  1. problem on handling keyboard in opengl
    By abubaker in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 06-01-2013, 08:30 PM
  2. mouse handling very slow since drivers > nvidia 90
    By henniman in forum OpenGL: Windows
    Replies: 2
    Last Post: 12-06-2006, 11:23 AM
  3. Fast mouse handling tips?
    By advil_user in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 02-14-2006, 07:14 AM
  4. mouse and keyboard control using GLUT.
    By in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 09-06-2003, 10:52 AM
  5. NURBS and mouse handling
    By in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 02-02-2001, 12:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean