SDL and why I don't like it

Started by
25 comments, last by 23yrold3yrold 18 years, 1 month ago
I don't like SDL very much. I think it doesn't do what it does terribly well - it's not very useful either for newbies (who it just confuses), or experienced game programmers (who it just annoys) SDL can be used in the following ways:

1. To create a software rendering engine

Well, at least, it could be, if it actually had any software rendering functions. It can't even draw a (diagonal) line on its own, so you'd need SDL_gfx or something. It can't even say "Hello, World" on its own, so you'd need SDL_ttf or something similar. What they've done, is put a wrapper around the functions that they know are hardware-accelerated under DirectDraw - and nothing else. So unlike Allegro, you can't actually make a useful software rendering engine unless
  • You are prepared to write your own line, circle, sprite, text, blending, etc routines
  • OR you are prepared to use a number of third party libraries - which would be fine, except these libraries are not usually bundled with SDL and aren't necessarily trivial to build.
I was making a SDL game for a competition. A 48 hour competition. I thought "Great, I'll develop this on Linux, and it will be a cinch to build on win32". I was wrong. SDL itself works fine on win32, but I *HAD* to use a text library - SDL_ttf - which, it turns out, didn't build trivially (although I did get it to build eventually, even though it did involve linking its .c files with my code in my own Makefile (yuk))

2. As a platform-independent way to get a GL context

Well, this is at least slightly more usable. With GL, you don't actually need a line drawing routine etc, because you can use opengl calls to do that sort of thing. Great - EXCEPT, this confuses newbies, who are constantly asking "Why does XXX software rendering function in SDL, not work in GL mode properly" ? Because the core of the library was made for doing software rendering (although not actually providing a wide selection of primitives), those functions are not necessarily going to work entirely correctly (or quickly) in GL mode.

Other things

What about input and sound, you might ask? Well, I can't fault the input handling really. But the sound handling has the same problem as the graphics - it's implemented at TOO low a level to really be useful - hence why many SDL games use SDL_mixer or something.

Alternatives

For software rendering, of course, you can bolt on the numerous extra software-rendering libraries (SDL_gfx and its friends) - provided you can get them to work on the range of platforms you intend to develop on. You could also just use Allegro instead - I know the API is somewhat idiosynchratic - I know that *some* of its functions are somewhat obsolete (fixed point maths) - but the software rendering functions are solid, and pretty much WORK. It's all one lump. You don't need anything else. If you just want an OpenGL context, why not use one of the libraries that just does that instead? Like GLFW, which is nearly as portable as SDL, and much more straightforward to use, opengl-wise (it doesn't pretend to do software rendering). Mark
Advertisement
Quote:Original post by markr
OR you are prepared to use a number of third party libraries - which would be fine, except these libraries are not usually bundled with SDL and aren't necessarily trivial to build.

This seems to be the bottom line of your first point: A lot of SDL functionality is available only through add-ons which are tricky to build.

This is obviously a problem, but I have trouble seeing it as any more than a minor one. How long did it take you to iron out the build process? 2 hours? That's 4% of the total contest time. And in a normal situation, of course, the percentage would be much less. In an ideal world, all libraries will install and build seamlessly... but when they don't, it's usually only a problem when starting out.

The moral of the story: If you're going to be doing a 48-hour development competition, get your ducks in a row BEFORE the contest begins. I mean, you didn't wait until the contest started to install GCC, right?

Quote:Great - EXCEPT, this confuses newbies, who are constantly asking "Why does XXX software rendering function in SDL, not work in GL mode properly" ?

That's reasonable... I'd like to see the runtime spit out warnings when 2D SDL graphics calls are made while in GL mode.
Mark, you bring up some very good points, but you miss the concept as a whole. SDL is not going to hold your hand, it isn't going to do anything but enable you. And that is something it does very well.

Allegro is a horible sloppy mess, and it makes me cringe when i look through sample code. all I have to say is, END_OF_MAIN(); Macro trickery is the devil. There is that, and allegro doesn't prefix any of their functions, so chances of namespace collisions are freaking huge.

I see no problem with the add on libraries. Most of them are fairly well documented, and all have similar syntax. Once you learn SDL_Mixer, you can learn SDL_ttf, or SDL_Image.

And why were you building all the libs from scratch? There are binaries for Windows...
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
Works fine for me, and it's a hell of a lot easier to set up a quick application than Directx.

Granted, DirectX totally blows SDL away with it's power, but I'm not going to be doing any 3D WOW games any time soon.

Gardon
Quote:Original post by Gardon
Works fine for me, and it's a hell of a lot easier to set up a quick application than Directx.

Granted, DirectX totally blows SDL away with it's power, but I'm not going to be doing any 3D WOW games any time soon.

Gardon


???

with OpenGl (through SDL ) you can get 3D WOW games if you want.
&& on most platforms( practically ).

i like SDL && i ike the fact that it's segregated, that way i only include the stuff i need, and
i suppose it would make the library build times shorter. i've been using it for a few
months, and i never needed to build it or any of the "major" companion librarys.



Not to jump TOO hard on the bandwagon...:)

I think the goal of SDL (originally) *was* to be used as an abstracted layer for software rendering.

A lot (a lot) of successfull indie projects have used SDL, and nobody has problems getting anything hooked up properly with OpenGL..

It takes what? 5-8 lines of code to find a pixelformat and create a surface for OpenGL?

SDL is a breath of fresh air.


Recently, I've been developing a project using SDL. The conclusion I have is that there is no point in using SDL, if the only things you want it do with it is creating a window and OpenGL context. You can do that on your own as well - and it's not much difficult at all.

Further more, SDL_Timer is nothing you should think of when making a serious game. It's simply lacking precision. Instead, you should go for same platform-specific performance counters.

I don't use SDL_image or SDL_whatever at all, since they only complicate the stuff. There are plenty of other libraries offering a better support and more features.

SDL_Input is not that bad but I've noticed some delays when handling keyboard events.

Generally, I am not really a proponent of SDL but still - it's quite simple library which completly satisfies needs of an amatour's game. That's why I use it. ;)

Cheers'

___Quote:Know where basis goes, know where rest goes.
Quote:Original post by clapton
Recently, I've been developing a project using SDL. The conclusion I have is that there is no point in using SDL, if the only things you want it do with it is creating a window and OpenGL context. You can do that on your own as well - and it's not much difficult at all.


Yes, you can do it yourself on Win32, Linux, MacOS X, BeOS, IRIX, Unix, FreeBSD, OpenBSD, Solaris, MacOS classic etc. - you can once again reinvent wheel.

Quote:
Further more, SDL_Timer is nothing you should think of when making a serious game. It's simply lacking precision. Instead, you should go for same platform-specific performance counters.


You can't have portable timer with resolution better than 1 milisecond on all comptuters - and that's what SDL gives.

Btw, if you are interested, developers are planning to use RTDSC on x86 platforms in next versions of SDL.

Quote:
I don't use SDL_image or SDL_whatever at all, since they only complicate the stuff. There are plenty of other libraries offering a better support and more features.


They complicate stuff???? Man, you must be blind.

With SDL_Image the only thing that you have to do, in order to load: PNG, GIF, JPEG, TIF, TGA, BMP, PCX, PNM, XCF or XPM is use this function:

SDL_Surface * IMG_Load(const char *file);

It spits out newly created SDL_Surface, or 0 when error occured. It's compatible with all 32, 24, 16 and 8 bits versions of aforementioned image formats. You call that complicated???

Ok, SDL_TTF is a little different story... but you said that SDL_Image is complicated, which simply isn't true.

Quote:
Generally, I am not really a proponent of SDL but still - it's quite simple library which completly satisfies needs of an amatour's game. That's why I use it. ;)

Cheers'


You call Neverwinter Nights amatour's game? ;-)
Um, like almost all linux ports of windows games use SDL.
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
Quote:Original post by PnP Bios
Um, like almost all linux ports of windows games use SDL.


It's a damn sight easier than working with OpenGL, which takes longer. And also OpenGL's just a graphics library, SDL provides the keyboard inputs etc.

This topic is closed to new replies.

Advertisement