Question regarding SDL implementation

I am currently writing an elaboration about SDL for my Programming finals,
but I have a question that I have not yet
been able to answer.

Lets take the functions GS_LockHWSurface(_THIS, SDL_Surface *surface)
//from the PS2 implementation
and DX5_LockHWSurface(_THIS, SDL_Surface * surface)

My question is now: How does SDL distinct between those 2 for example, and
call the DX5 function on a
Win32 platform, and the GS function on a PS2?

Are they re-#defined at compile time, or called in super-functions?
I have not been able to find the correct .h or .c file yet to look it up.

Any help would be greatly appreciated.

There are two sorts of “selection”: Compile time and run time.

At compile time, autoconf and #defines controls what code gets compiled in. That’s pretty much required to be able to build SDL at all, since it contains lots of code that can only be compiled on certain platforms. (Most people don’t have Mac OS headers on their Linux or Windows development systems, for example - and they wouldn’t be of much use anyway, as the generated binaries would not even load anywhere.)

When SDL initializes a subsystem, it will one way or another, determine which one of the available backends (there is more than one on most platforms) to use. An instance of that backend is created, and the pointer to it is placed in a global variable. The structure contains (among other things) pointers to all low level functions of that backend, so that the SDL API calls can find them.

For a very simple example of both kinds of “selection”, you may have a look at my smoothscroll demo, found at;

http://olofson.net/mixed

It supports using both SDL and OpenGL for rendering, and (unless I made some stupid mistake :slight_smile: it should compile into an SDL only version if OpenGL is not available in the build environment.

//David

.---------------------------------------
| David Olofson
| Programmer

david.olofson at reologica.se
Address:
REOLOGICA Instruments AB
Scheelev?gen 30
223 63 LUND
Sweden
---------------------------------------
Phone: 046-12 77 60
Fax: 046-12 50 57
Mobil:
E-mail: david.olofson at reologica.se
WWW: http://www.reologica.se

`-----> We Make Rheology RealOn Fri, 7/06/2002 18:02:37 , Hermann Scharitzer wrote:

I am currently writing an elaboration about SDL for my Programming finals,
but I have a question that I have not yet
been able to answer.

Lets take the functions GS_LockHWSurface(_THIS, SDL_Surface *surface)
//from the PS2 implementation
and DX5_LockHWSurface(_THIS, SDL_Surface * surface)

My question is now: How does SDL distinct between those 2 for example, and
call the DX5 function on a
Win32 platform, and the GS function on a PS2?

Are they re-#defined at compile time, or called in super-functions?
I have not been able to find the correct .h or .c file yet to look it up.

By the way, the URL you mentioned (http://olofson.net/mixed) is not valid :confused:

Thank you for the great info! :slight_smile:

http://olofson.net/mixed.htmlOn Fri, Jun 07, 2002 at 10:10:14PM +0200, Hermann Scharitzer (O-Hare) wrote:

By the way, the URL you mentioned (http://olofson.net/mixed) is not valid :confused: