3 questions / suggestions

Hello!

I have 3 questions. Some of it has been discussed a long time ago, but
I still haven’t seen any replies or solutions. I also have a new request.

  1. Right now it is necessary to include SDL.h in the file containing the main
    function for SDL to work - where SDL.h mangles the main function
    (e.g. to WinMain). I would really like to avoid this mangling - in
    a nice, official and clean way.

    Are there any API-calls for doing the necessary initialization?
    Like SDL_InitMain / SDL_ExitMain or something? On e.g. Windows this
    will of course require that I make my own WinMain function, but this
    is exactly what I’m looking for.

    If this is not avaliable then I would claim that this would be a very
    Good Thing ™ to have in SDL. It might even be doable in a way which
    actually refactors the code into such 2 functions and thus makes the code
    nicer.

    I need it to support SDL in an ML-compiler (MLton) for Linux and Windows
    without having a mangled main, since this will require SDL to be included
    in the compiler’s runtime-library. So the compiler becomes dependent
    on SDL - which is very bad.

  2. Is support for multiple windows in SDL still being planned / worked on? :slight_smile:
    A long time ago I was told that it’s planned for version 1.3 / 2.0 but
    I can see that almost one year ago Sam posted that it’s not supported yet.

  3. A new idea / request: It would be really nice if an SDL-application
    is able to determine if SDL is installed or not before trying to
    open SDL. Here I am thinking of something like popping up a Window
    using the platform’s native GUI if SDL is not installed. To be really
    cool the dialog of course ought to have explanations and links to the
    SDL website etc. (maybe even a clickable link and an OK button to
    continue running the SDL application after SDL is installed…) :slight_smile:

    I actually started writing some code for this for Windows at some point
    but didn’t have time to finish it back then. I guess I could make it more
    complete and post it here if it has any interest.

    If you look at my question number 1 above, I think this would be another
    situation where it is necessary that the mangled main function does not
    do any initialization of a library which is not installed yet.

    These things (both the main-thing and the install-thing) could sensibly
    be located in a separate file called something like preSDL.h or something
    like that. It should of course all be coded in the headerfile so that
    this code is always linked statically with the applications using SDL.
    One could then include preSDL.h in the file with main instead of the
    normal SDL.h. Of course the main-name-mangling could still be
    supported and include the install-SDL-query-thing automatically.

What do you say? :slight_smile:

If I look into actually coding this (not the multiple windows though…),
can someone then incorporate it into the official code?
And is this OK with the designers of SDL?

Cheers–
http://www.HardcoreProcessing.com

  1. Right now it is necessary to include SDL.h in the file containing the main
    function for SDL to work - where SDL.h mangles the main function
    (e.g. to WinMain). I would really like to avoid this mangling - in
    a nice, official and clean way.

Are there any API-calls for doing the necessary initialization?
Like SDL_InitMain / SDL_ExitMain or something? On e.g. Windows this
will of course require that I make my own WinMain function, but this
is exactly what I’m looking for.

The problem is that the “pre-main” initialization is VERY different on
the various platforms. It’s not a matter of just calling a function on
MacOS X, for example. You actually have to have resources to set up the
main window.

However, on Windows you can call SDL_SetModuleHandle(GetModuleHandle(NULL));
from your WinMain() before calling SDL_Init(), and you’ll be fine.

  1. Is support for multiple windows in SDL still being planned / worked on? :slight_smile:
    A long time ago I was told that it’s planned for version 1.3 / 2.0 but
    I can see that almost one year ago Sam posted that it’s not supported yet.

It’s planned, but it’s on the long term todo list.

  1. A new idea / request: It would be really nice if an SDL-application
    is able to determine if SDL is installed or not before trying to
    open SDL. Here I am thinking of something like popping up a Window
    using the platform’s native GUI if SDL is not installed. To be really
    cool the dialog of course ought to have explanations and links to the
    SDL website etc. (maybe even a clickable link and an OK button to
    continue running the SDL application after SDL is installed…) :slight_smile:

You could do this now, if you dynamically opened the SDL shared object,
loaded all of SDL’s functions, and popped up a message window if you
couldn’t find the SDL shared object. Since you need to do all this
without knowing whether or not SDL is installed, it falls outside of
the SDL API. :slight_smile:

See ya!
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Sam Lantinga wrote:

The problem is that the “pre-main” initialization is VERY different on
the various platforms. It’s not a matter of just calling a function on
MacOS X, for example. You actually have to have resources to set up the
main window.

However, on Windows you can call SDL_SetModuleHandle(GetModuleHandle(NULL));
from your WinMain() before calling SDL_Init(), and you’ll be fine.

OK - so I guess this has to be OS-specific in some way. What about a standard
function for each supported platform? Like e.g.:

SDL_PreInitWindows( /* arguments from WinMain or whatever is needed / );
SDL_PreInitX11Unix( /
arguments from main or whatever */ );
etc.

I guess it would be OK if the parameterlist is different and
very platform specific for each platform. But at least having
an “official” way of doing it which is not considered a hack
would be very nice.

  1. Is support for multiple windows in SDL still being planned / worked on? :slight_smile:
    A long time ago I was told that it’s planned for version 1.3 / 2.0 but
    I can see that almost one year ago Sam posted that it’s not supported yet.

It’s planned, but it’s on the long term todo list.

OK :slight_smile:

  1. A new idea / request: It would be really nice if an SDL-application
    is able to determine if SDL is installed or not before trying to
    open SDL. Here I am thinking of something like popping up a Window
    using the platform’s native GUI if SDL is not installed. To be really
    cool the dialog of course ought to have explanations and links to the
    SDL website etc. (maybe even a clickable link and an OK button to
    continue running the SDL application after SDL is installed…) :slight_smile:

You could do this now, if you dynamically opened the SDL shared object,
loaded all of SDL’s functions, and popped up a message window if you
couldn’t find the SDL shared object. Since you need to do all this
without knowing whether or not SDL is installed, it falls outside of
the SDL API. :slight_smile:

OK - however I guess it would be of use for many applications using
SDL. If I get something like this up and running (even just for
Windows) I will probably still post it or throw it on my website.
Then I hope others might be interested in using it and extending it
for all the supported platforms eventually.


Cheers–
http://www.HardcoreProcessing.com

SDL_PreInitWindows( /* arguments from WinMain or whatever is needed / );
SDL_PreInitX11Unix( /
arguments from main or whatever */ );
etc.

I guess it would be OK if the parameterlist is different and
very platform specific for each platform. But at least having
an “official” way of doing it which is not considered a hack
would be very nice.

Well, this would work for Unix (no init necessary), Windows (only one function),
but it wouldn’t work for MacOS X, which needs resources in the app, and a few
others.

My point is that there is no one function that you can call that will do the
pre-init for every platform. That’s why it’s structured the way it is. If you
want to write your own platform specific code that’s different from the SDL’s
code, that’s fine, and the hooks are there for you to do that.

You could do this now, if you dynamically opened the SDL shared object,
loaded all of SDL’s functions, and popped up a message window if you
couldn’t find the SDL shared object. Since you need to do all this
without knowing whether or not SDL is installed, it falls outside of
the SDL API. :slight_smile:

OK - however I guess it would be of use for many applications using
SDL. If I get something like this up and running (even just for
Windows) I will probably still post it or throw it on my website.
Then I hope others might be interested in using it and extending it
for all the supported platforms eventually.

Cool! :slight_smile:

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment