OpenGL/GLUT app cannot gain focus when forked from a terminal app

Discussion in 'Mac Programming' started by evilxsystems, Aug 20, 2009.

  1. evilxsystems macrumors newbie

    Joined:
    May 11, 2006
    #1
    Hi-

    I'm having an issue with OpenGL/GLUT. I have a command line application that I'm trying to add some graphics to in a separate window. I'm using GLUT and I can open the window fine, can draw to it just fine. I'm using a pthread to run GLUT in it's own thread so I don't have to rewrite my whole app to use GLUTs event based model...but I would like to use GLUT generated events to do things in the GLUT window, however I can't seem to get the window to respond to input...I can pass the GLUT thread commands generated in the terminal window, but when I click on the GLUT window I get the spinning ball mouse cursor and my GLUT input event handlers never get called...is this a problem with running GLUT in a pthread? or am I missing something simple?

    Also I'd like to do away with GLUT if possible and use OpenGL directly, is there a tutorial on how to launch a separate window and do OpenGL in it from a terminal app?....also I really want to avoid X11 if possible.

    -thanks
    jason
     
  2. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #2
    Look into SDL, it may well provide a solution for all the things that you have mentioned and has the added advantage of being cross platform compatible too if you ever want to deploy your application on Windows or Linux.
     
  3. evilxsystems thread starter macrumors newbie

    Joined:
    May 11, 2006
    #3
    :)
    I was using SDL1.2, but I had to switch to x86_64 mode to deal with some memory issues. Tried using SDL1.3 in 64bit mode on the mac...can't get the framework to compile and from the sounds of it it won't be stable for a while.
     
  4. evilxsystems thread starter macrumors newbie

    Joined:
    May 11, 2006
    #4
    this approach works fine if the GLUTmainloop is called from the main thread of the application and main code of the original application is then run on in a pthread.
     

Share This Page