Re: [AD] Non C program accessing Allegro on OS X

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]



Peter Hull wrote:

On Friday, October 28, 2005, at 01:42  pm, Jon Rafkind wrote:

I mean at what point does the OS X code get called? I tried calling the OS X setup code by hand but this doesnt work. I think things would work if the OS X init code occured somewhere during install_allegro, no?


No, a lot of it has already happened by then. The Application object gets created and its run loop is started. Normally the app would get a didFinishLaunching notfication, then it would enter its run-loop, processing events. Allegro apps never exit from didFinishLaunching, instead they spawn a thread with the user code, and stay in their own event/screen-update loop. SDL does the same kind of thing, but, because SDL apps use an event queue, they don't need to spawn a thread.

Here is what I tried with limited success.. from mzscheme I call a function, hack_the_mac, which in turn spawned a new thread that ran the main OS X event loop, the one present in main.m. Then I returned control back to mzscheme and loaded up allegro and whatnot. This actually worked, to my surprise, but something was chewing up the CPU and the Allegro window did not seem to respond to system input from the keyboard or input. When I hovered the mouse over the window it turned into the spinny color wheel thing.

So then I tried a sort of different approach, but along the same lines. In the hack_the_mac function I again spawned a new thread and ran the same exact code thats in the main() function of main.m. The whole

AllegroAppDelegate * delegate = [[ AllegroAppDelegate alloc] init];
...
[NSApp run];

And instead of calling user main in app_main() I just did nothing. But now when this starts up I dont see applicationDidFinishLaunching being called ever. Why is this? Is it because this NSApplication thing has to be run by the starting thread? If so, is there any way around this?




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/