Skip to content

SDL template

Semphriss requested to merge Semphriss/ut-app-meta-template:sdl into master

I've been advised to share this here!

I've made a template for SDL-based apps. Since SDL3 has Wayland support, it works properly with Ubuntu Touch. This can help greatly with the porting of SDL-based games.

I'm not sure about the best practices, so I went for the simplest solution I could make: download the SDL3 source code, and include it with the codebase in CMake with a simple add_directory. I've made a basic template based on what I could understand by myself, but if there's any interest in adding this officially, it would be good to pass behind be to check if I did a good job.

Some thoughts about my current implementation;

  • add_directory() is a pretty dirty way of handling the SDL3 dependency. It does have the advantage of not constraining all apps to a single version of SDL3, but it requires downloading and compiling SDL3 manually, pollutes the environment in CMake, and ships all apps with their very own SDL. The best would be to have a separate PPA and host SDL3 and its satellite libraries for 20.04 and the soon-to-come 24.04. If not, the add_subdirectory() could be replaced with an ExternalProject_Add(), which would be cleaner but have the disadvantage of being scarier and overall more complex.
  • I haven't added any satellite library (SDL_image, SDL_ttf, etc.) myself, but I've left (very basic) instructions on how to add them.
  • I tried to keep the template app as simple as possible, hence why it currently only shows a white screen.
  • I did my best to integrate my code seamlessly, but I have a feeling that many of my changes are pretty ugly.

If this sounds interesting, I'm willing to discuss and adapt it as necessary.

Merge request reports