Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: I am developing a game using 2 engines - comparison  (Read 3904 times)

0 Members and 1 Guest are viewing this topic.

Tenry

  • Full Member
  • ***
  • Posts: 120
  • Experienced Programmer
    • View Profile
    • Simon-Burchert.com
I am developing a game using 2 engines - comparison
« on: January 22, 2014, 05:08:20 pm »
Hello everybody,

I am currently working on a 2D platformer game using various libraries for certain tasks. But for the most general functions - window, graphics - I am using two libraries: SFML and SDL. Nope, I am not using them both the same time. Instead I am developing two versions of the game: one based on SFML, the other one on SDL.
Reasons why I am doing this is because I like SFML and I believe that the new SDL 2 isn't bad, either. Both have their pros and cons (there are tons of discussions, speed tests etc. on the web), but I will do the direct comparison in a real case example. There are issues I am encountering and I want to share them with you while developing on that game. When the game is (almost) finished, I will propably decide for only one of the two versions, but as of now, I am developing both.
Note, that I an not using any of these two libraries for loading graphics from the files or playing music/sfx.

Feel free to discuss about my points.




Key Mapping
The first "issue" I encountered is the key mapping. I am using a configuration file where the key mapping is set. Each action (jump, move, confirm, ...) is assigned a "key" to. That might be a key of the keyboard, a button of the joystick etc. I wanted to use a common config file for both game versions, but I found out that the both the keyboard "key codes" and the gamepad "button indices" differs in SFML and SDL. I'd prefer SDL's way of identifying the keys either by standardized scancodes or physical location. SFML instead gives the keys completely different IDs, making the configuration incompatible to each other. There was already a discussion about it in the SFML forums, and I think, it's even an issue in the SFML tracker.
I am confused about the different button IDs of the same gamepad in the libraries (using Windows), more details to come...



Graphics Engine
SFML is completely OpenGL based, whereas with SDL the programmer has the choice (Direct3D, OpenGL or even Software-rendered). I tested the SDL version on WinXP in a virtual machine, but I couldn't initialize Direct3D nor OpenGL, only the software-version worked (which is propably the slowest of these). I feared that SFML wouldn't work at all (OpenGL), although it might only be a VM issue. But luckily, the SFML version runned in the VM without any issues! :)



Threaded Loading (Textures)
Loading textures in a separate thread is quite easy in SFML. You need to care about activiating the OpenGL context in the thread, you are currently working in, but that's all. There's even a tutorail about this in SFML's wiki.
SDL, however, does not support this feature, as far, as I know. There is even a ticket about that issue.
« Last Edit: February 13, 2015, 02:51:00 pm by Tenry »
Please note that my previous display name was "Shy Guy".

Assassin0795

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: I am developing a game using 2 engines - comparison
« Reply #1 on: January 22, 2014, 07:35:37 pm »
Hm, I've used SDL 1.2 a bit (and SFML), and didn't mind the way keys were mapped in either engine. Of course, what I developed wasn't exactly consumer-ready nor all that far along, and the applications were separate rather than trying to have the two imitate each other.

Regardless, I'm interested to see your thoughts/comparisons of the two.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10826
    • View Profile
    • development blog
    • Email
AW: I am developing a game using 2 engines - comparison
« Reply #2 on: January 23, 2014, 08:06:16 am »
Better key handling is on its way, not sure if Laurent has made a decision yet.
Also assuminv that "codes" are equal between libraries is a flawed assumption from the beginning. Instead you'd havd to abstract the codes again and use your own ones for thd config file.
With SFML you could use Thor's action map. ;)

SFML was never meant to have different backends and especially no software renderer, since that was exactly the one of the reasons why SFML was built. ;)

As for you VM you'll need to activate GPU rendering.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Tenry

  • Full Member
  • ***
  • Posts: 120
  • Experienced Programmer
    • View Profile
    • Simon-Burchert.com
Re: AW: I am developing a game using 2 engines - comparison
« Reply #3 on: January 23, 2014, 03:45:26 pm »
Better key handling is on its way, not sure if Laurent has made a decision yet.
Yeah, I read a recent topic about it here (by Laurent I think), where it was discussed and compared with other libraries.

Also assuminv that "codes" are equal between libraries is a flawed assumption from the beginning. Instead you'd havd to abstract the codes again and use your own ones for thd config file.
With SFML you could use Thor's action map. ;)
There are generally 2 ways how the config file might identify the keys:
  • library-independent: I store scancodes or key names, and convert them to the lib-specific IDs.
  • library-depentent: I store the codes given by the lib (with SFML it's the enum values, with SDL I can choose whether I want the scancodes or the physical position related codes).
At the moment I am the second version (having 2 different config files, one for each library) to avoid the need of a long switch-case or other kind of long mapping data.
The key (and gamepad button) mapping is almost fully implemented, I am not using Thor's libraries, but thx ;)

SFML was never meant to have different backends and especially no software renderer, since that was exactly the one of the reasons why SFML was built. ;)
That's okay, that's why it is called a simple library.

As for you VM you'll need to activate GPU rendering.
Possible. But strangely, the SFML version worked without any problems, although it uses OpenGL in any case. With SDL, I couldn't initialize OpenGL. Maybe there's a version issue or something...
Please note that my previous display name was "Shy Guy".