SDL main within a module

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

SDL main within a module

Asko Kauppi

I have a problem.

Some architectures -particularily OS X- supported by SDL  
(www.libsdl.org) require the SDL_main function to actually overwrite  
main, being "in between" system, and the application main function.  
Normally, this makes sense and is easily implementable (almost  
transparent) but...

I am moving LuaX, and its SDL module to work with _stock_ _unaltered_  
Lua 5.1 core. Which, of course, won't allow SDL_main to run above  
itself.

What shall I do?  Any ideas and discussion is welcome.  Does someone  
know, how other SDL bindings (Ruby, Python..) have overcome this?  
Have they?

-asko

(this message has been separately mailed on both Lua and SDL mailing  
lists)
Reply | Threaded
Open this post in threaded view
|

Re: SDL main within a module

Alex Queiroz
Hallo,

On 4/29/06, Asko Kauppi <[hidden email]> wrote:
>
> What shall I do?  Any ideas and discussion is welcome.  Does someone
> know, how other SDL bindings (Ruby, Python..) have overcome this?
> Have they?
>

     I'm not sure I've understood your problem. Since it's a module to
be loaded by Lua, why do you need a main() function?

--
-alex
http://www.ventonegro.org/
Reply | Threaded
Open this post in threaded view
|

Re: SDL main within a module

Asko Kauppi

On certain systems, initialization of SDL library is done before main() is called, by 'hijacking' main into
the SDL codebase (-lsdlmain). This is not possible from within an extension module, since a main loop
is already up and running.

Anyways, this seems to be a known issue also on SDL list, and there is hope SDL 1.3 shall "fix" it,
offering an alternative initialization/cleanup scheme.  

-asko

Lainaus Alex Queiroz <[hidden email]>:

> Hallo,
>
> On 4/29/06, Asko Kauppi <[hidden email]> wrote:
> >
> > What shall I do?  Any ideas and discussion is welcome.  Does someone
> > know, how other SDL bindings (Ruby, Python..) have overcome this?
> > Have they?
> >
>
>      I'm not sure I've understood your problem. Since it's a module to
> be loaded by Lua, why do you need a main() function?
>
> --
> -alex
> http://www.ventonegro.org/
>
Reply | Threaded
Open this post in threaded view
|

Re: SDL main within a module

Alex Queiroz
Hallo,

On 4/30/06, [hidden email] <[hidden email]> wrote:
>
> On certain systems, initialization of SDL library is done before main() is called, by 'hijacking' main into
> the SDL codebase (-lsdlmain). This is not possible from within an extension module, since a main loop
> is already up and running.
>

     Maybe you could use a wrapper script that sets LD_PRELOAD and
then call the Lua executabe. Not beautiful, but...

--
-alex
http://www.ventonegro.org/
Reply | Threaded
Open this post in threaded view
|

Re: SDL main within a module

Asko Kauppi

That's a unique idea, thanks... But it is not that different from  
making a separate 'lua51-sdl' binary, just for the sake of SDL  
initialization.  The end result remains, which is SDL's need to  
"hijack" the main loop (and this issue is more of SDL's than Lua's,  
so let's stop?).

:)   -asko


Alex Queiroz kirjoitti 30.4.2006 kello 23.49:

> Hallo,
>
> On 4/30/06, [hidden email] <[hidden email]> wrote:
>>
>> On certain systems, initialization of SDL library is done before  
>> main() is called, by 'hijacking' main into
>> the SDL codebase (-lsdlmain). This is not possible from within an  
>> extension module, since a main loop
>> is already up and running.
>>
>
>     Maybe you could use a wrapper script that sets LD_PRELOAD and
> then call the Lua executabe. Not beautiful, but...
>
> --
> -alex
> http://www.ventonegro.org/