|
|
(6 intermediate revisions by 4 users not shown) |
Line 1: |
Line 1: |
| == Porting SDL applications to OS/2 == | | == Porting SDL applications to OS/2 == |
|
| |
|
| === Requirements ===
| | Moved to [http://www.edm2.com/index.php/SDL] |
|
| |
|
| To port SDL applications to OS/2, you'll need the latest SDL binaries
| | [[Category:Delete]] |
| and header files from Netlabs. Currently the OpenWatcom compiler is
| |
| <b>the</b> compiler for the OS/2 port of SDL, but it should also work
| |
| with GCC.
| |
| | |
| === Using the OpenWatcom compiler ===
| |
| | |
| There are some requirements and tricks with using the OpenWatcom compiler
| |
| to port SDL applications. You should note the followings things.
| |
| | |
| ==== Use the -ei switch for the OpenWatcom C compiler ====
| |
| | |
| You have to use the <i>-ei</i> switch for the OpenWatcom C compiler to
| |
| have the size of enums equal to the size of ints. This is a requirement of
| |
| SDL itself.
| |
| | |
| ==== Wrapping the SDL_Quit() function ====
| |
| | |
| The OS/2 version of SDL is compiled into a DLL file. This DLL file has all
| |
| the SDL functions exported by name. In order to be able to use this DLL from
| |
| the most compilers, these exports are using the <i>_Syscall</i> calling
| |
| convention. This leads to problems with some SDL apps, where they assume that
| |
| the calling convention of the API is the same as the calling convention of
| |
| their runtime library. For example, the following line is very usual in SDL
| |
| applications:
| |
| | |
| ...
| |
| exit(SDL_Quit);
| |
| ...
| |
| | |
| This should be worked around by creating a wrapper function for SDL_Quit, and
| |
| using that one, this way:
| |
| | |
| #ifdef __WATCOMC__
| |
| void SDL_Quit_Wrapper()
| |
| {
| |
| SDL_Quit();
| |
| }
| |
| #endif
| |
| ...
| |
| #ifdef __WATCOMC__
| |
| exit(SDL_Quit_Wrapper);
| |
| #else
| |
| exit(SDL_Quit);
| |
| #endif;
| |
| | |
| === Using the GNU C Compiler ===
| |
| | |
| Hmm, needs somebody who has experiences with it. :)
| |
| | |
| === General tips and tricks ===
| |
| | |
| ==== Morph your program to a PM program at runtime ====
| |
| | |
| Most SDL applications assume that they can write to STDOUT, and the user will
| |
| see it. In OS/2, you have to compile your application to a PM application in
| |
| order to be able to have a PM Window, but the STDOUT will go to NULL in this
| |
| case. The solution is to compile your code to a VIO application, and morph the
| |
| application to a PM one dynamically, at runtime, before calling SDL_Init().
| |