Why would I choose SDL2 over SFML?

I have novice C++ experience, I have played with SFML before but i hear SDL2 is more cross platform. Is this true? My question is in your opinion; Why I would use SDL2 over SFML?

Thak you in advance. I am also asking the opposite question on the SFML forums.

2 Likes

Or maybe not many people here use SFML so we can’t answer your question!

Generally we’re focused on building the best library we can, and feel people should use whatever makes them happy, whether it’s our work or someone else’s.

2 Likes

I recently bounced between several libraries. SFML->Raylib->Allegro and now SDL2 which I dismissed in the beginning for something newer. There’s a reason games made in SDL a decade from now are still running fine today. My needs might be a little different, I want to be able to run my projects on Raspberry Pi. But I wasted a lot of time when I could have been up and running same day.

1 Like

For me, I honestly chose SDL2 mainly because it was the first library I received a recommendation for that was easy to find a tutorial for. So I really can’t speak to SFML or any other library, but I can at least state some of the reasons I love SDL2:

  1. It’s absurdly flexible. I’ve yet to want to do something that SDL can’t accommodate, even if it takes a bit of DIY. My current project can load textures from my own custom archive format, can load textures from the output of a third-party rasterizer library, and has a pair of custom audio effects that I actually coded into the executable itself, complete with fade in and fade out. It does all of this totally in-memory with no temp files, pipes or additional processes. And to top it all off, it’s written mostly in Ada.

  2. It has great compatibility. I’ve gotten my stuff to run on both Windows 10 and Raspbian Stretch, and there are ports for other platforms too.

  3. It’s very stable. If anything goes wrong, it returns a null or an error value and keeps ticking. Getting it to crash is more or less impossible, as long as you follow the guidelines documented on the wiki. Plus, it has great error reporting.

  4. It’s fairly well-documented and there’s an active community. Though there are a few exceptions, you can find just about anything you need on the wiki, or ask on the forums.

(This is my reasoning, mistakes are possible*)
Pluses:

  1. The size:
    SFML with SFML-window and SFML-server - 10mb,
    SDL2(core) and SFML(ttf) is 1621 kb.
  2. Crossplatform.
    GitHub has a list of all supported platforms.
    There are more of them than SFML(
    Minuses:
  3. SDL2 doesn’t have everything that SFML does.
    This can not be attributed to the minuses.
    SDL2 is more of a support tool than a complete graphics library.
    Evidence:
    It doesn’t implement the convenience of working with shaders or the ease of working with opengl
    (like in SFML), in SDL2 it is more like the GLEW principle.

But this minus does not bother me, I myself added support for shaders. Therefore, my choice remained on SDL2.

2 Likes

I built the exact same Tetris game using Raylib, SDL, Allegro, and SFML. I ultimately stuck with SDL for all future game development and improvements for two reasons.

SDL does not force you to use C++ if you don’t want to. I only use C because C++ is hard on my brain.

SDL programs also launch a ton faster than those built with Raylib or SFML. SDL and Allegro are both smaller and modular in that you only compile the modules you need, and this leads to quicker recompile and running while developing.

1 Like

You don’t need to reply to threads that’ve been dead for 2-3 years.

But years ago, I wasn’t a member of this forum yet. I meant no harm.