From: Joe L. <jfl...@dg...> - 2002-02-25 03:57:53
|
Hi, Sorry for the cross-post - this really involves both Tcl/Tk and GLUT pretty equally. I'm wondering if anyone has tried or has suggestions on integrating GLUT and Tcl/AquaTk into the same application. FYI, this is to bring a free for non-commercial (and source-available) physics-based animation research application that runs on unix & Windows to Mac OS X and maybe let one of the researcher's who wrote it use it on his TiBook. I believe the app. is used by a number of universities. This integration is pretty straightforward (if not very pretty) in linux, SGI and Windows. The basic way things work on the other platforms is as follows: main() - sets up glut, including an idle callback, myGLUTIdleCallBack() - calls TkMain() (never to return) with a callback of myTkAppInit() (a tweaked version of tkMacOSXAppInit() on OSX) myTkAppInit() - setup tcl/tk more or less as in tkMacOSXAppInit() - creates a one-time tcl timer to fire in a short time calling myMainLoop() myMainLoop() - calls glutMainLoop() (never to return) myGLUTIdleCallBack() - calls Tk_DoOneEvent(TK_DONT_WAIT) until it returns 0 (i.e. no events left) The program flow is as follows: main() --> TkMain( ... , myTkMacOSXAppInit ) --> myTkMacOSXAppInit() --> TclCreateTimer( ... , myMainLoop ) [Tcl timer fires:] myMainLoop() --> glutMainLoop() (spins in here, calling) [every GLUT idle callback:] myGLUTIdleCallBack() --> Tk_DoOneEvent(TK_DONT_WAIT) (handle pending Tcl/Tk events) The above only sort of works on MacOS X. Setup all seems ok, the GLUT idle and display callbacks get called ok, the tk shell/console works ok and the windows (both GLUT and Tk/Wish) can all be moved around BUT - the GLUT window never becomes the frontmost (it's always 'dimmed' or whatever it's called) - GLUT mouse and key event callbacks don't get called My guess is that the problem is a conflict between GLUT's event handling and AquaTk's event handling. It seems to work on other platforms because they probably have event callbacks registered for each window by the respective libraries and everyone is happy, but in MacOS X it seems like AquaTk is stealing other window's events. This was *definitely* a problem in Classic MacOS, which I tried hacking together way back and gave up on doing cleanly. Any help/suggestions would be greatly appreciated. Unfortunately, I don't have a lot of time to spend on this, but I'd really like to see this app. on MacOS X. Joe. |