SDL(Simple Direct Media Layer)

I bought the book “Programming linux game” and it was good. I would like to learn more SDL, what is a good book on SDL. Also I hear in the next few years SDL may surpass directx, because of it’s portability, ease of use, and still being capable of directly working with the system like directx.

DirectX and SDL and entirely different things.

The best way to learn SDL is to get the source, and just build and trace through the various examples available. This will not only teach you how SDL works, but how various people write code, too, which is a good thing.

Originally posted by jwatte:
DirectX and SDL and entirely different things.

Why is that?
They’re both media layers. They both manage such things like hardware surfaces, sound, cd-rom access, and so on…

I don’t see where DirectX can do things SDL cannot…

Well, enough for that troll

Julien.

Hey,
SDL uses DirectX. So DirectX isn’t going anywhere.

The way I learned SDL was by downloading the source code and printing out all the header files and looking at all the functions and stuff. It’s pretty simple to figure it out how to use it from there. It’s not so different from any other media layer type API like DirectX so if you have experience using one you will pick up SDL really quick.

How can SDL use DX if it runs on Linux, BeOS, Irix and Solaris ?

SDL uses OpenGL, OpenAL,etc…

OldMan, why not? Each platform has its own API, and DirectX happens to be used (among others) on Win32. See here and here .

[This message has been edited by Maj (edited 10-31-2002).]

I use linux at home, and linux at school, consequently I have programmed on both systems, and on windows SDL may use some directx, but there is no directx at all on linux. Over all SDL is not just an API to make directx easier as glut is to GL, SDL is it’s own API, which will eventually beat Directx

You are right, SDL is an API, but it cannot beat DirectX because of a simple reason:

DirectX is part of the operating system.

For some things there is no way to access it without DirectX, so SDL has to use DirectX on Windows. Ok, for 3D graphics there is OpenGL and for sound there is OpenAL, but for example for input there is only DirectX.

You can not write an API that doesn’t use another existing API without access to either the operating system (only MS can do that) or to the device drivers (only the device manufacturers can do that).

In Linux it is different, because it is open source, but SDL uses an existing API (like X or svgalib) with linux, too.

SDL is just a common API that uses some operating system dependant libraries like DirectX, XWindows, svgalib and so on. DirectX doesn’t need to use any other API, since it is part of the OS.

Btw: SDL does not use OpenGL, it only supports creating rendering contexts, that means it uses (again depending on the operating system) GLX, WGL, …

thats like saying opengl cant ‘beat’ directdraw (or d3d) cause opengl often uses directdraw for the drawing under windows.
personally sdl is beautiful + exactly what a api should be. extremely simple and low level i would hate it if they added stuff like model loading etc to sdl (its ok for a library over the top of it but not to sdl)

You realize that SDL does not come with specific device driver support, right? Meanwhile, OpenGL and DirectX both provide driver APIs for vendors to implement to.

I’m sure that SDL is a great wrapper that makes it easy to move applications across OSes (although I found the OpenGL context setup code rather lacking). However, it’s just that – a wrapper API. It’s not a device access API in itself, and it’s certainly not a device driver API.

Thus, SDL is something different than DirectX or OpenGL, and talking about SDL “beating” DirectX is like saying that a Corvette will eventually “beat” gasoline.

It depends of course a whole lot what you mean with “beat”. While SDL will never be able to add more functionality than what the underlying API’s provide it might provide a better and easier to use interface and you may call that “beat”. SDL may grab a lot more attention such that in the future more people use SDL than DirectX directly, in that case you could also say that it has beaten DirectX in a way.

Originally posted by Overmind:
Ok, for 3D graphics there is OpenGL and for sound there is OpenAL, but for example for input there is only DirectX.

I wouldn’t go as far as to say that DirectX is the only input API for Windows. GLFW does not use DirectInput, yet it has splendid support for keyboard, mouse and joystick input.

Anyway, your point is right - you need to use SOME API - for sound you can use Windows Multimedia system (winmm.dll) or DirectSound, and for graphics you have GDI, DirectDraw, OpenGL etc.

It uses DirectX on Win32. If you don’t believe me download the fargin source and read it your self! I knows because I have worked extensively with SDL in the past few months.

It DOESN’T use directX on systems without DirectX obviously. On Linux it uses OSS for sound I believe. On WIn32 it uses DirectSound. It doesn’t use OpenAL. You have to do that yourself (which I am working on right now).

It DOES allow you to use OpenGL, not Direct3D. DirectX on Win32 is for input and sound only.

Oh, and I also agree, the SDL lacks in alot of details. It is great as a simple media layer, but it’s problem is sometimes you need to do platform specific things that SDL doesn’t let you get at.

All in all SDL is great for what it does, it makes media programming alot easier. But with that simplicity you also lose alot of control over your application on specific platforms. With directx you have alot more options on Windows. All SDL does is take the lowest common denominator on all systems and merge it into a simple interface.

Maj … I looked at the links you passed me. These look like wrappers that use SDL to export a DX interface. In fact a fake DX that uses SDL.

Probably the same kind of thing used to port DX applications to linux under SDL.

Erm, no, they’re a DX implementation of the SDL video and audio interfaces. SDL_SetVideoMode -> DX5_SetVideoMode, etc. Go up a directory and you’ll see the drivers for x11, svgalib, quartz, etc. Look at DX5_CreateDevice and note how it’s filling in a jump table from …/SDL_sysvideo.h.

Well as for accessing such things as hardware with direct input, opengl allows you to access the key board, mouse, and a joystick, and opengl was around before directx, so it is possible for SDL to have direct input without reaching for it from directx.