Start with SFML or SDL?

Started by
11 comments, last by jbadams 11 years, 9 months ago
Hey
I have been programing c++. I would like to start programming games and I heard that SFML and SDL would be good to start and to do great games, but witch one should I use. I also would like to ask for good tutorials for SDL and SFML.
Thanks.
Advertisement
It's not the end of the world if you choose one or the other. You really could pick either one and be just fine. This question gets asked all the time.

So I'll answer it the same as I've always answered it: I'd say go with SFML 2.0. It's great. It's got tutorials written by its author (he's still writing more) (SFML 1.6 tutorials can be used and pretty easily converted to SFML 2.0 while the author is still working on more 2.0 tutorials). SFML is incredibly simple and intuitive to use, I've found, and it's got good forums for support and questions. The main reason I say SFML, however, is that it's written in C++ and you're using C++, so it just feels more intuitive to use. If you used SDL, it's written in C, and mixing C and C++ is just fine if you know what you're doing, but if you're still learning C++ (which I'm assuming you are) you might get some C habits mixed in your C++ habits, which isn't the best way to learn things.

If, at the end of the day, you still can decide, flip a coin. The time you spend debating between one or the other is better spent just learning one.
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]
To be honest I started a project with C++ and SDL, was going perfectly until sprite rotation. SDL isnt friendly with sprites to be honest, and as it uses the CPU only and not the GPU it isnt very good to do the rotation on the fly, as it could cause major lag on many machines, If you want to create a quite simple basic game or program I would say go for SDL as it is nearly supported by everything, If you want something that uses the GPU and doesnt cause a huge amount of process to the CPU go for SFML. I converted all my SDL project to SFML in a very short time, and as I have worked with SDL before I feel that SFML is much easier and well...just easier to understand.

Canvas
SDL 1.3 (now named 2) runs on OpenGL behind the scenes, so it's the same as SFML regarding that.

I'd still go for SFML because it's easier to use, and the things that SDL supports and SFML doesn't (like multiple windows) are generally not needed.
@wolfscaptain: SFML supports multiple windows.
Lazy Foo's SDL tutorials are very popular if you wanted to go the SDL path.


Both APIs are very capable, and the core functionality is very similar (and as noted above, the latest version of SDL does use hardware rendering like SFML where possible) although you'll probably find that due to it's age there are more add-ons for SDL ('though due to their age some of them may not be currently maintained! wink.png). Both APIs are very popular and have active and helpful communities. The documentation provided for SFML is fairly detailed and provides plenty of information to get started, but you'll probably find -- again due to the maturity of SDL -- that although SDL doesn't have quite as comprehensive official documentation there are quite a few more third party tutorials, articles and code samples available online; Lazy Foo's tutorials (linked above) are often suggested as a starting point for SDL, whilst SFML beginners simply start with the official documentation.

It mostly comes down to personal preference: I'd recommend taking a look at some of the tutorials and reference materials available for each API and choosing whichever makes more sense and looks like a better style to you.


All that being said, if you would like our suggested preferences, I personally prefer SFML -- I just felt the topic was a bit one-sided thus far and that SDL should also be properly presented as a viable choice, as both are capable APIs that you should be able to learn without undue difficulty. It's worth quickly noting also that due to the similarity of these (and other similar) APIs, if you learn either of them in detail you should find it relatively easy to learn the other at a later stage should you choose to do so.


Hope that's helpful! smile.png

- Jason Astle-Adams


To be honest I started a project with C++ and SDL, was going perfectly until sprite rotation. SDL isnt friendly with sprites to be honest, and as it uses the CPU only and not the GPU it isnt very good to do the rotation on the fly, as it could cause major lag on many machines, If you want to create a quite simple basic game or program I would say go for SDL as it is nearly supported by everything, If you want something that uses the GPU and doesnt cause a huge amount of process to the CPU go for SFML. I converted all my SDL project to SFML in a very short time, and as I have worked with SDL before I feel that SFML is much easier and well...just easier to understand.

Canvas


Actually, you can mix OpenGL and SDL for hardware acceleration. (Someone correct me if I'm wrong). Basically you would use SDL_opengl.h for SDL's OpenGL functions.

Anyway, for simplicity and moderate portability, go SFML.

For massive portability and moderate difficulty, go SDL.

I haven't really used SFML, I just really found out about it yesterday in fact. It's really simple, or maybe I say that because I've been working with OpenGL and SDL for a while now. I personally strongly recommend SDL, as it's well matured and it has great portability. It's also a great starting point for understanding how some of the behind the scenes magic works. To me, SFML's weakness is its simplicity. That's just my personal opinion, I like being able to see what I'm working with and make it work for what I want it to.

I may not be the best guy to get an opinion from as I did just find out about SFML yesterday, but I did test it and got it to work no problem.
There is a C variant of SFML if you dig around on the SFML-dev.org website, so you're not forced into incorporating C++ code into your project if that's your intent.

There is a C variant of SFML if you dig around on the SFML-dev.org website, so you're not forced into incorporating C++ code into your project if that's your intent.

Pretty unlikely given the OP specifically mentioned C++ and hasn't made mention of C...

- Jason Astle-Adams

I always go for SDL 1.2 with OpenGL for rendering. It's low level compared to most multimedia libraries and once you've done the init code and some basic abstraction over the event system you'll practically never touch SDL in your game again. That's the way I like it.

SFML has too many 'nifty' tools that I never use. It has the aim of being more of a helper library and tend to seep in everywhere. It just imposes itself a bit too much for my taste. The api is pretty OK for what it is though and most people doesn't want to get their hands gritty with opengl calls the way I do..

The many nifty things that it includes are indeed nifty, but they're usually not as versatile as if you'd get another specialized library for the specific purpose. It has network sockets for instance, which is nice and all, if you want something really simple in that way, but they are fairly limited.

If you need the easy basics of rendering a 2D game you should go for SFML. But if you're like me and want to try a few more advanced techniques on your own and rather not have anything in your way, I'd say SDL because it's just there silently in the background.

This topic is closed to new replies.

Advertisement