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

Author Topic: Difficuly of porting SFML to SDL  (Read 2750 times)

0 Members and 1 Guest are viewing this topic.

timebender

  • Newbie
  • *
  • Posts: 6
    • View Profile
Difficuly of porting SFML to SDL
« on: October 05, 2022, 08:18:25 pm »
Hello,
during the summer break, I started coding in SFML, only to recently learn that we use SDL / OpenGL in school. But I don't want to switch so fast, because I just got used to SFML and yeah.

I don't need to make the jump right now. This year, we are supposed to make a game and hand it in in April. Before that, I don't need any knowledge of SDL.
So my question is; How difficult would it be, if I made the game in SFML first and then port it to SDL after it is all finished? Or are there significant issues in doing so?

The game should be quite simple. There will be no shaders or anything of the sort. Just sprites, basic transformations and the sort.

Thank you in advance!
« Last Edit: October 05, 2022, 08:23:23 pm by timebender »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Difficuly of porting SFML to SDL
« Reply #1 on: October 06, 2022, 08:41:48 am »
Haven't really done much SDL development, especially not in the past few years, so might not be the best to answer this.
You'll most likely need to rewrite all the nice SFML abstractions such as sf::Sprite or sf::RectangleShape etc. and figure out the equivalent functions for the operations in SFML (e.g. how to change a view or handle events or open a window, etc.).
Since SDL is C, you may also want to introduce some classes to deal with RAII, as to ensure that the destroy functions are already called.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Jim Marsden

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: Difficuly of porting SFML to SDL
« Reply #2 on: November 11, 2022, 08:57:25 pm »
The short answer is some, how events are done are different. But unless you did a lot of abstracting everything that touches SDL I think you'd run into some pain. They have so much overlap, and interface very differently. One is a great C library and the other is a fantastic C++ library.

If I were to do it, I would do templates, and c++20 concepts. That way I could rely on polymorphism to do the magic for me.

Elias Daler

  • Hero Member
  • *****
  • Posts: 599
    • View Profile
    • Blog
    • Email
Re: Difficuly of porting SFML to SDL
« Reply #3 on: November 30, 2022, 01:33:02 pm »
I'd recommend reading my post on my experiences of porting my engine from SFML to SDL: https://eliasdaler.github.io/porting-to-sdl/

Basically, the more you wrap SFML types/functions into abstractions, the easier it will be to port. I'd also recommend to use something like glm instead of sf::Vector/sf::Rect everywhere.
Tomb Painter, Re:creation dev (abandoned, doing other things) | edw.is | @EliasDaler