Lately I started using SFML instead of SDL for C++ Game Development. However, I'll still use SDL on future projects I hope. It's a brilliant library, so compact and portable that the games you write will be able to be compiled to a lot of platforms, even high school graphing calculators[1].
The SDL development still impresses me and 2.0.0 is a major milestone and multiple windows, new OpenGL, touch support, Android and iOS support are here to keep SDL alive with all the new frameworks and "engines". I hope it does well!
I really like SFML, I've been using for a small game project of mine as well. The API is just nice and beautiful.
I was wondering how SDL 2.0 stacks up against SFML? Does anyone know much about it?
I'm only doing 2D game development, so SDL's "simple 2D rendering API that can use Direct3D, OpenGL, OpenGL ES, or software rendering behind the scenes" is perfect for my needs. However it needs to support two basic things:
* Rotation (additional matrix transformation like scaling & shearing would be nice as as well)
* Transparency (being able to apply a color filter not necessarily limited to the alpha channel, like an RGBA filter would be nicer)
Does it support the above? (I'm guessing it does -- just want to be sure.)
Also, I know Android/iOS support for SFML is in the pipeline, but the fact that it's not ready yet is another reason it might be good to switch to SDL 2.
Looks like they changed their license from LGPL to zlib as well. I wonder if this will increase adoption, or if it just was so Valve could use it in Steam for Linux.
I doubt it would be a huge issue for Valve; they already use LGPL code. However, it's often a big deal for small developers; simpler licenses mean simpler due diligence on investment and such, and a lot of companies are cautious of LGPL in anything that they'll be distributing.
"Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D. It is used by video playback software, emulators, and popular games including Valve's award winning catalog and many Humble Bundle games."
I wrote a silly (unfinished) game about 10 years ago, and SDL portability never ceases to amaze me. The game has been ported to devices I didn't even know they existed.
It's amazing because I did it for fun and I used some data structures I would have never expect to be so portable (ie. using a double linked list of objects in static memory instead of alloc/free). I wonder if that's why it works even in very limited hardware.
SDL_main is no longer mandatory (though it is still there); #define-ing SDL_MAIN_HANDLED and calling SDL_SetMainReady once before SDL_Init is sufficient now.
Edit: Ah, if the main loop you refer is SDL_Event loop, as exDM69 said, SDL always supported passive event functions that can be called at your original idle function. SDL 2.0 adds an active event watcher (SDL_AddEventWatch etc.) as an alternative though.
OpenGL is a platform-independent API for graphics. SDL is a platform-independent API for everything else relevant to the game development, and also provides an initialization procedure for OpenGL (which OpenGL itself does not provide, so you needed to use platform-specific APIs like WGL and AGL or later standards like EGL).
Isn't SDL the simplest, most portable way to use OpenGL?
OpenGL by itself is useless, it just does 3D graphics, and its GLUT library is too bare-bones to be of much use. SDL is a good, portable chassis for OpenGL application that don't need native GUI integration. An SDL OpenGL app will compile and run almost anywhere, with minimal fuss. Compare that to using OpenGL contexts inside platform-specific toolkits.
SDL is a decent cross-platform layer for handling things like window creation, event handling, joystick and other devices, and things like this.
However, if you're using OpenGL, there are at least two libraries you'll probably want to make heavy use of (because SDL doesn't do anything worth mentioning in those regards):
I used SDL 2 after Sam's "please use SDL 2 and report problems" email about 2 or 3 years ago and it was a pleasant experience and a much needed upgrade over SDL 1 (though most of the docs were still incomplete). So this announcement makes me happy.
I have been using SDL2 for awhile now and it is a great library. It was definitely not ready until now though. I still need to rewrite my game engine to work with the current version. I am happy to hear this will be the last rewrite though!
Woo! I have been using SDL for years to build all sorts of projects (games, touch screen interfaces, etc.).
But as others here have noted I migrated over to use SFML, mainly because of its nice object-oriented implementation as well as the additional convenience features such as rotation and better alpha support.
Great library. Simple to use and efficient. I have been using it for some time. I have created a little TMX file reader aiming at game development. C is hard but fun:
Awesome work, I'm looking forward to use it! I always liked the combination of SDL+OpenGL. Clipboard support is also very exciting because using X for that in Linux is a nightmare :)
Let me guess: it's still impossible to minimize a full screen game on Linux or alt-tab etc., and the joystick will still not be recognized if you plug it in after the game starts.
> Let me guess: it's still impossible to minimize a full screen game on Linux or alt-tab etc.
You can hardly blame SDL for this, games are not really what X11 was designed for. Setting up full screen and asking for exclusive access to the keyboard will prevent the window manager from doing anything to it.
My solution for this problem: use a window manager that can full screen any window and switch back.
> and the joystick will still not be recognized if you plug it in after the game starts.
To be fair, 99% of AAA games don't support joystick hotplugging either. It's really annoying.
Since you have not checked whether this is actually the situation and do not properly understand the other components in the equation, I find your attitude offensive.
[+] [-] munchor|12 years ago|reply
The SDL development still impresses me and 2.0.0 is a major milestone and multiple windows, new OpenGL, touch support, Android and iOS support are here to keep SDL alive with all the new frameworks and "engines". I hope it does well!
[1]: http://www.omnimaga.org/index.php?topic=12378.0
[+] [-] winter_blue|12 years ago|reply
I was wondering how SDL 2.0 stacks up against SFML? Does anyone know much about it?
I'm only doing 2D game development, so SDL's "simple 2D rendering API that can use Direct3D, OpenGL, OpenGL ES, or software rendering behind the scenes" is perfect for my needs. However it needs to support two basic things:
* Rotation (additional matrix transformation like scaling & shearing would be nice as as well)
* Transparency (being able to apply a color filter not necessarily limited to the alpha channel, like an RGBA filter would be nicer)
Does it support the above? (I'm guessing it does -- just want to be sure.)
Also, I know Android/iOS support for SFML is in the pipeline, but the fact that it's not ready yet is another reason it might be good to switch to SDL 2.
[+] [-] angersock|12 years ago|reply
[+] [-] chrisballinger|12 years ago|reply
[+] [-] munchor|12 years ago|reply
>This means that it's okay to statically link SDL2 into your game, instead of needing to ship a folder full of shared libraries! xD
source: [1]: http://www.reddit.com/r/gamedev/comments/1k9ila/sdl_20_has_b...
[+] [-] belorn|12 years ago|reply
[+] [-] rsynnott|12 years ago|reply
[+] [-] scoopr|12 years ago|reply
[+] [-] EzGraphs|12 years ago|reply
"Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D. It is used by video playback software, emulators, and popular games including Valve's award winning catalog and many Humble Bundle games."
http://www.libsdl.org/index.php
[+] [-] reidrac|12 years ago|reply
[+] [-] bloodorange|12 years ago|reply
Nevertheless, I will give it a shot again.
Good work Sam!
[+] [-] exDM69|12 years ago|reply
SDL has never hijacked the main loop, unlike e.g. GLUT. SDL has SDL_WaitEvent and SDL_PollEvent and leaves the main loop to you.
[+] [-] reidrac|12 years ago|reply
It's amazing because I did it for fun and I used some data structures I would have never expect to be so portable (ie. using a double linked list of objects in static memory instead of alloc/free). I wonder if that's why it works even in very limited hardware.
My favourite, the game running on a TI-Nspire calculator: http://www.youtube.com/watch?&v=acdAqxiwG7I&t=15
[+] [-] lifthrasiir|12 years ago|reply
Edit: Ah, if the main loop you refer is SDL_Event loop, as exDM69 said, SDL always supported passive event functions that can be called at your original idle function. SDL 2.0 adds an active event watcher (SDL_AddEventWatch etc.) as an alternative though.
[+] [-] frozenport|12 years ago|reply
[+] [-] lifthrasiir|12 years ago|reply
[+] [-] mahmud|12 years ago|reply
OpenGL by itself is useless, it just does 3D graphics, and its GLUT library is too bare-bones to be of much use. SDL is a good, portable chassis for OpenGL application that don't need native GUI integration. An SDL OpenGL app will compile and run almost anywhere, with minimal fuss. Compare that to using OpenGL contexts inside platform-specific toolkits.
[+] [-] angersock|12 years ago|reply
However, if you're using OpenGL, there are at least two libraries you'll probably want to make heavy use of (because SDL doesn't do anything worth mentioning in those regards):
FreeImage for image loading ( http://freeimage.sourceforge.net/ )
AssImp for model loading ( http://assimp.sourceforge.net/ )
Both are amazingly handy, have good licenses, and have excellent documentation (FreeImage is one of my favorite tech writing examples of all time).
[+] [-] dkersten|12 years ago|reply
[+] [-] SteveDeFacto|12 years ago|reply
[+] [-] 0xdeadbeefbabe|12 years ago|reply
[+] [-] thecodemonkey|12 years ago|reply
But as others here have noted I migrated over to use SFML, mainly because of its nice object-oriented implementation as well as the additional convenience features such as rotation and better alpha support.
[+] [-] batiste|12 years ago|reply
https://github.com/batiste/sdl2-game-loop
[+] [-] jamesmiller5|12 years ago|reply
[+] [-] zokier|12 years ago|reply
[+] [-] Aardwolf|12 years ago|reply
[+] [-] telephonetemp|12 years ago|reply
[+] [-] aktau|12 years ago|reply
[+] [-] shmerl|12 years ago|reply
[+] [-] ambrop7|12 years ago|reply
[+] [-] exDM69|12 years ago|reply
You can hardly blame SDL for this, games are not really what X11 was designed for. Setting up full screen and asking for exclusive access to the keyboard will prevent the window manager from doing anything to it.
My solution for this problem: use a window manager that can full screen any window and switch back.
> and the joystick will still not be recognized if you plug it in after the game starts.
To be fair, 99% of AAA games don't support joystick hotplugging either. It's really annoying.
Since you have not checked whether this is actually the situation and do not properly understand the other components in the equation, I find your attitude offensive.
[+] [-] hnha|12 years ago|reply
[+] [-] jlgreco|12 years ago|reply
I'm not sure how it handles it, but kerbal space program doesn't have this problem in linux.