Any Tips on porting from DirectDraw to SDL

Hi all,
As you may or may not know, Siege of Avalon has been open sourced ( - it is Win32 Pascal code before you all rush off
and download it ).

I have put together a team to continue working on this excellent game
and we will be porting the game to JEDI-SDL and therefore Linux as well
as adding new features to the engine.

For those of you who have ported DirectX engines to SDL, what steps have
you taken to make the transition a smooth one?

Do you attack ports of this nature in a methodical manner?

What steps do you take?

It may be a good idea for someone how has experience in this area to
write a small tutorial or overview of tips, tricks and pitfalls that
DirectX to SDL developers should look out for.

The order that I plan for us to do this ports is as follows…

  1. The Input Handling routines/System.
  2. Going from DirectDraw surfaces to SDL surfaces ( including Alpha
    blending, Color Keying etc.
  3. Porting assembler routines to native Pascal for better portability
  4. Porting sounce routines to SDL.

I am open to any feedback as this is the first major port I will be
working on.


Dominique := go on, write a game instead;

I’ve never done DirectX stuff, but in the past, I have ported some of my simple
little X-Window games for the “Agenda VR3” Linux-based PDA to SDL, so that they’ll
run on the Sharp Zaurus (which has SDL-on-top-of-Qtopia), and, obviously, elsewhere
(Linux desktop, Windows, etc.).

One game, “Agendaroids,” was ported to SDL to become the desktop (and then, later,
Sharp Zaurus) game “Vectoroids.”

It’s a small program, and only one C source file, so it was pretty trivial to go
in and start yanking “#include <X/foo.h>” lines, and then compiling…
seeing what errors I get… fixing them… lather, rinse, repeat. :slight_smile:

Another game, “BrickOut,” I wanted to keep as an X-Window game, AS WELL AS being

To this, I used compiler preprocessor stuff (e.g., “#ifdef USE_SDL” … “#endif”).

But, rather than have to duplicate or abstract tons of code where I was making
X-Window calls, since most X stuff (event-handling, for example) is very similar
to SDL stuff, I literally did crazy things like:

(#ifdef USE_SDL…)

typedef SDL_Surface * Drawable;
typedef int Display;
typedef Uint32 GC;
typedef SDL_Event XEvent;
typedef SDLKey KeySym;

which allowed me to keep using all of the same variables which were previously
declared as types defined by X. (e.g., X’s “Drawable” became an SDL “SDL_Surface *”)

and, where necessary, tweaking function calls, like:

#ifndef USE_SDL
while (XPending(display))
XNextEvent(display, &event);
while (SDL_PollEvent(&event) > 0)


Anyway, I know that doesn’t help directly, but it might give you ideas for
ways to go about the DirectX -> SDL port.

Good luck!

-bill!On Fri, Aug 01, 2003 at 06:16:18PM +0100, Dominique Louis wrote:

For those of you who have ported DirectX engines to SDL, what steps have
you taken to make the transition a smooth one?

bill at Got kids? Get Tux Paint!