osx - Haskell SDL on OS X -


SDL on OS X With the use of preprocessor tricks, main () with its own entry point written in Objective-C Does the caller, who calls the user's main

These tricks make life of non-SDL users (eg: hosel binding) very difficult.

Is there a good reason for this?

Why can not the objective-coco initialization in SDL SDL_init? Outlook for Mac OS X Other non-Linux platforms (Windows, Mac, BOS)

Is not very different from. You can ask yourself from SDL developers why they did this, but I can get many reasons to see this:

  • It is dependent on the SDL code, which is focused on the SDL - Specific sub-systems (video, audio, timing, etc.) are limited to specific subsystems that are specifically designed to work with SDLs. To wit. In this way, SDL leans and keeps mean.
  • This application avoids introducing a new platform-specific subsystem to launch everyone's bogeys app objects and menus that the SDL sets for the Mac app, not the long shot To - so if you put it in SDL_init , then you will need it to create an optional subsystem, it does not require inconvenience developers.
  • It handles the reverse of the control correctly, which is usually operated on Mac OS X and other application frameworks while maintaining the operation, SDL_init assumes that the SDL routine terminology is that after starting it The caller is returning, but if you tried to naive to create an application object in SDL_init and turn on the [app run] application Starting and launching For, you never coming back. If you did not call run , you will need to create a separate SDL function to set the application run loop. This can make SDL libraries a bit complicated. The chosen approach, avoids all this, sets the framework first by looking after all the applications, and invokes the SDL_main () routine from applicationDidFinishLaunching .
  • This makes it easy to convert the SDL demo coded on Mac OS X to Linux. You do not even need to change the name of the main name - main to rename SDL_main

    I'm guessing these last reasons Which is the main code to SDL_main.h , which I believe is an ugly hack.

    If you are ready to leave cross-platform portability for your library and app, then I would like to remove your SDL_main.h line from:

      #define main SDL_main  

    and remove the following from SDLMain.m in your project:

      #ifdef Main # Unf main #endif  

    If you do this you do not need to compile the SDL again. Note that SDLMain.m is already set to SDL_main () without any pre-launching hack, and there is nothing else in SDL, so in this way From you, you can only provide SDL_main () as the entry point of your game.

    If you want to go to the other side, then main still by #define main SDL_main in the hack SDL_main.h Want to get rid of, but besides, you main) SDL provides for you. First of all, note that SDLMain {H, m} is not part of the library; You should include them separately in your project. Second, note the following comments in SDLMain.h :

      / * SDLMain.m - our coco-enabled SDL application Main entry point for initial version: Darrell Wallis and Lieutenant; Dwaliss1@purdue.edu> Non-NIB-code & amp; Other changes: max horn & lt; Max@quendi.de> Feel free to customize this file to meet your needs. * /  

    I think if this is not working for you, then it will work for you Like to invite, SDLMain {H, m} as a model and if you are rolling your own, you can do whatever you like! For that matter, you can write in the Haskell equivalent to SDLMain.m , if you want to know what it is. Unless you have any footage with HOC, though, I want to keep it simple.


Comments