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

    May 11, 2006

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

  2. Cromulent macrumors 603


    Oct 2, 2006
    The Land of Hope and Glory
    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

    May 11, 2006
    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

    May 11, 2006
    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