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.

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.

1 Like

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.

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.