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

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


On Mon, 2005-10-24 at 23:48 -0400, Jon Rafkind wrote:
> Im using Allegro with bindings written in Scheme( MzScheme ) but am 
> running into problems on OS X. This works fine on Linux, though. 
> Basically how its set up is I load allegro.so( or in this case 
> allegro.dylib ) and extract functions from it which I can then call just 
> like I would from C. In this way the "magic main" in OS X isnt run and 
> things dont seem to work right when this is the case. Im not very 
> familiar with the OS X internals and KittyCat was telling me it wasnt 
> really possible to run Allegro on OS X without the magic main but Im 
> hoping this can be changed so it works the same on Linux.
> 
> I did a bunch of debugging by adding printf's into the Allegro internals 
> but couldnt really come up with anything since I think two or more 
> threads are doing stuff once I activate allegro via install_allegro. One 
> thing I did come up with is that if I dont have a main then __crt0_argv 
> isnt set and in system.m line 489 will crash. This should read
> 
> else if ( __crt0_argv != NULL ){
>       do_uconvert(__crt0_argv[0], U_ASCII, output, U_CURRENT, size);
>    }
> 
> instead.
> 
> Any OS X have any insight into this problem?
> 

Basically, you must give control of the main thread to Allegro. You can
see what Allegro does at startup in src/macosx/main.m. The main()
function in there is the main function of any standalone Allegro
program, the main() in your code gets basically renamed to something
else with END_OF_MAIN.

So, while I don't know any details either about OSX nor accessing the
shared library, maybe you can write a small wrapper function which does
the same as this main() function in main.m, and make it call a function
in your code to be executed as a separate thread in the same way.

I don't know if it will work. And maybe someone else has a better idea,
some people have already written bindings for other languages, even
including Scheme I think.

[Oh, and in new_api_branch this will be easier I guess, since there it
will be enough to query for new events from your main thread from time
to time - so Allegro doesn't need the main thread for itself anymore.
So, just prod everyone to hurry up with releasing 4.2.0, and then after
that releasing the first version with the new code - where then what you
are trying to do should be easy :)]

-- 
Elias Pschernig





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