EiffelMedia: SDL Hack

PreviousNext

Overview

Unfortunately it was impossible to develop the EiffelMedia Vision2 Widget without a little hack into the original SDL Library. A reason for this hack is that Windows uses separated environment variable blocks for the application and its dll's.

The only thing that this hack does is to activate two deactivated SDL functions on Windows and Linux. These functions are 'SDL_putenv' and 'SDL_getenv' which gives the possibility to set the SDL_WINDOWSID variable on time and therefore to draw the SDL surface into the right client window.

How to Hack the SDL Library

This hack is very simple to do. The best way to do this on Windows System is with Visual Studio. First Open the SDL.sln project and add 'SDL_getenv.h' (from {SDL_SRC}/include/) and 'SDL_getenv.c' (from {SDL_SRC}/src/) to your project.
With the free Borland Compiler it is nearly impossible to build the SDL library. There are lots of errors and missing things inside the included Borland project files. If someone knows how to build SDL with the free Borland Compiler please contact the EiffelMedia developer team.

Open 'SDL_getenv.h' in you favorite editor and then you will find following 3 lines:
#if defined(macintosh) || defined(_WIN32_WCE)
#define NEED_SDL_GETENV
#endif

Then you only have to uncomment two of those lines like this:
// #if defined(macintosh) || defined(_WIN32_WCE)
#define NEED_SDL_GETENV
// #endif

Compile your project in release mode and then you can use the generated SDL.lib, SDLmain.lib and SDL.dll in your EiffelMedia Project.

Building libs for Borland

It was very hard to find a way to build a working Borland library without having a specific dll for Borland systems. The easiest way is to use the SDLmain.lib provided with the original SDL packages. This file is located in {SDL_SRC}/Borland/lib. to create a working SDL.lib in Borland format simply use the command tool 'coff2omf' provided with the free Borland Compiler.

Following Command should do the trick:
cd 'where you have you MSC libs'
coff2omf {msc_lib_location}/SDL.lib {bcb_lib_location}/SDL.lib

If everything is ok, you have now your working set of SDL libs for the free Borland Compiler.

SDL Hack on Linux

There is no need to do anything on Linux systems. Simply use the standard SDL libraries version 1.2.9.

SDL Hack on Mac OS X

Noting has to be done on this platform. 'SDL_putenv' and 'SDL_getenv' are available by default because Mac OSX has no _putenv, _getenv in their C libraries.