Skip to content

SDL GUI backend#1251

Open
mmuman wants to merge 19 commits into
brndnmtthws:mainfrom
mmuman:gui-sdl
Open

SDL GUI backend#1251
mmuman wants to merge 19 commits into
brndnmtthws:mainfrom
mmuman:gui-sdl

Conversation

@mmuman

@mmuman mmuman commented Oct 13, 2022

Copy link
Copy Markdown
Collaborator

The idea is to be able to run Conky on ancient OSes and hardware (thinking about MiNT (not the GNU/Linux distro, the Atari OS) or AmigaOS), in a regular window but with minimal coding required, and also to allow testing the GUI backend without X11. I used SDL 1.2 because SDL2 only runs on Windows, OSX and Linux, which limits the interest for old platforms.

For now it only draws text with a hardcoded font. It also still needs to be compiled with X11 due to some variables here and there.

@netlify

netlify Bot commented Oct 13, 2022

Copy link
Copy Markdown

Deploy Preview for conkyweb canceled.

Name Link
🔨 Latest commit 41b49ab
🔍 Latest deploy log https://app.netlify.com/sites/conkyweb/deploys/67963c4a1792480008511ac2

@github-actions github-actions Bot added the sources PR modifies project sources label Oct 13, 2022
@mmuman mmuman force-pushed the gui-sdl branch 3 times, most recently from 8f1477e to cca610b Compare November 29, 2022 21:36
@mmuman

mmuman commented Nov 29, 2022

Copy link
Copy Markdown
Collaborator Author

I added some way to locate and load TTF files by the font name, it kinda works.
Screenshot_20221129_223721

@mmuman

mmuman commented Jan 22, 2023

Copy link
Copy Markdown
Collaborator Author

Just rebased, had to change some #ifdef info #if defined(BUILD_WAYLAND) || defined(BUILD_SDL) so maybe we'd need some BUILD_NONX11 define around to avoid these lists everywhere?

@brndnmtthws

Copy link
Copy Markdown
Owner

Just rebased, had to change some #ifdef info #if defined(BUILD_WAYLAND) || defined(BUILD_SDL) so maybe we'd need some BUILD_NONX11 define around to avoid these lists everywhere?

That could work, though it seems messy. There's also BUILD_GUI, but it sounds like that won't help here.

@mmuman

mmuman commented Aug 4, 2023

Copy link
Copy Markdown
Collaborator Author

The recent changes on color stuff just got rid of the #ifdef thing.

@mmuman

mmuman commented Aug 5, 2023

Copy link
Copy Markdown
Collaborator Author

And we have colors :-)

@Caellian

Copy link
Copy Markdown
Collaborator

Hi, I changed how registration of output displays works to avoid linker magic, you can check out how other backends are registered on main branch for reference.

Main differences are:

  • sdl-output.cc should be guarded by build flag in CMakeLists.txt
  • You need to provide a log message template fallback in display-output.cc for feature gated outputs

@github-actions github-actions Bot added dependencies adds or removes dependencies, or suggests alternatives build system related to build system (CMake) and/or building process/assumptions labels Jul 6, 2024
@github-actions github-actions Bot added the rendering related to code that handles rendering, excluding the used graphics API label Jan 23, 2025
@mmuman

mmuman commented Jan 23, 2025

Copy link
Copy Markdown
Collaborator Author

Rebased, updated to last renaming, and should be up to @Caellian 's changes too.
Still not finished.

@mmuman mmuman force-pushed the gui-sdl branch 2 times, most recently from 991a97c to c25df8a Compare January 23, 2025 23:19
@mmuman

mmuman commented Jan 23, 2025

Copy link
Copy Markdown
Collaborator Author

(of course, pushing from wrong machine…)

@mmuman mmuman marked this pull request as ready for review January 26, 2025 02:28
@mmuman

mmuman commented Jan 26, 2025

Copy link
Copy Markdown
Collaborator Author

Default config now renders just fine.
Copie d'écran_20250126_032910

@github-actions github-actions Bot added documentation suggests documentation changes or improvements gh-actions suggest changing GitHub actions labels Jan 26, 2025
@brndnmtthws

Copy link
Copy Markdown
Owner

I fixed the font loading on macOS, and added some basic font caching.

However, I get a blank window on macOS with the default config:

Screenshot 2025-01-26 at 07 48 48

@brndnmtthws

Copy link
Copy Markdown
Owner

Not sure why the Nix build is failing, but it's fine to ignore it for now.

@mmuman

mmuman commented Jan 26, 2025

Copy link
Copy Markdown
Collaborator Author

Hmm probably something similar with how we accept GUI settings or not.

Btw, it fails to build on Haiku because ::map is not in <unordered_map>.

@mmuman

mmuman commented Jan 26, 2025

Copy link
Copy Markdown
Collaborator Author

Just to make sure, you might want to trace calls to set_foreground_color to see if it actually gets proper colors or just black.

@brndnmtthws

Copy link
Copy Markdown
Owner

Is there any reason we can't use SDL2 rather than 1.2? It seems like SDL 1.2 isn't as well supported by the distros.

Ubuntu doesn't appear to have SDL_ttf 1.2: https://packages.ubuntu.com/search?suite=noble&arch=any&searchon=names&keywords=libsdl-ttf

@brndnmtthws

Copy link
Copy Markdown
Owner

FWIW there's a decent migration guide here: https://wiki.libsdl.org/SDL2/MigrationGuide

@mmuman

mmuman commented Jan 26, 2025

Copy link
Copy Markdown
Collaborator Author

Yes, the idea is to run on very old OSes like Atari MiNT.

@brndnmtthws

Copy link
Copy Markdown
Owner

Yes, the idea is to run on very old OSes like Atari MiNT.

Ah, right, I see now that's in your original comment, but I had forgotten about it.

The SDL_ttf library is pretty tiny, I think we could just bundle it as a 3rd party source. It's literally just 2 source files (SDL_ttf.c and SDL_ttf.h). Then it can be used with the SDL 1.2 compat layer, which is widely available. What do you think of that?

@brndnmtthws

Copy link
Copy Markdown
Owner

One more thought: maybe we should make it more clear that we intentionally only support SDL 1.2, so that in the future we can support newer versions as well.

@brndnmtthws

Copy link
Copy Markdown
Owner

The SDL_ttf library is pretty tiny, I think we could just bundle it as a 3rd party source. It's literally just 2 source files (SDL_ttf.c and SDL_ttf.h). Then it can be used with the SDL 1.2 compat layer, which is widely available. What do you think of that?

Actually, this isn't as easy as I thought. SDL_ttf 1.2 depends on freetype 1, which is also somewhat deprecated.

At this point, I think it's better to just not support distros that don't ship with SDL1.2, or people can compile SDL1.2 (and its dependencies) themselves if they really want it in a modern distro that doesn't include all the SDL1.2 deps.

@mmuman

mmuman commented Jan 28, 2025

Copy link
Copy Markdown
Collaborator Author

I suppose we could support both with some #ifdef spaghetti.

@brndnmtthws

Copy link
Copy Markdown
Owner

I suppose we could support both with some #ifdef spaghetti.

This is less than ideal. It becomes really hard to maintain, and there are already a million different build options as it is.

I'd prefer to keep it simple, and since GitHub actions uses Ubuntu by default for the Linux CI, it would be good to make it compile on Ubuntu (and macOS too if possible). At least that way we can catch compiler errors.

Getting it to compile with Nix and macOS is pretty easy, but Ubuntu is a pain. Doing it in Docker would work, but I don't love that.

I guess we could use the ExternalProject feature of CMake, then it wouldn't be too hard to include both freetype 1 and SDL_ttf 1.2 as 3rdparty dependencies. While I don't like including 3rdparty code this way, in this case it makes some sense.

@mmuman

mmuman commented Jan 31, 2025

Copy link
Copy Markdown
Collaborator Author

Or just have a separate sdl2 display.

@Caellian

Caellian commented Feb 3, 2025

Copy link
Copy Markdown
Collaborator

Just to check, did rebasing to renamed files cause issues or did git figure out how to move things properly? I tried really hard to reduce the impact so I'm wondering whether it made any difference.

Or just have a separate sdl2 display.

This seems like the cleanest option from all angles (code, CMake, CI) - SDL_VERSION_MAJOR from FindSDL can be used to switch between includes and sources so it would only add one variable and work seamlessly for both.

Last (a bit crazy) option is to port SDL_ttl 1.2 to use TrueType 2, it's supported afaict. 😄

@mmuman

mmuman commented Feb 6, 2025

Copy link
Copy Markdown
Collaborator Author

Just to check, did rebasing to renamed files cause issues or did git figure out how to move things properly? I tried really hard to reduce the impact so I'm wondering whether it made any difference.

Just had to git mv the SDL ones.

This seems like the cleanest option from all angles (code, CMake, CI) - SDL_VERSION_MAJOR from FindSDL can be used to switch between includes and sources so it would only add one variable and work seamlessly for both.

I'll look into that later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build system related to build system (CMake) and/or building process/assumptions dependencies adds or removes dependencies, or suggests alternatives documentation suggests documentation changes or improvements gh-actions suggest changing GitHub actions rendering related to code that handles rendering, excluding the used graphics API sources PR modifies project sources

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants