Skip to content

Upgrade to SDL3#663

Merged
pzychotic merged 29 commits intomainfrom
sdl3
Feb 17, 2025
Merged

Upgrade to SDL3#663
pzychotic merged 29 commits intomainfrom
sdl3

Conversation

@Lgt2x
Copy link
Member

@Lgt2x Lgt2x commented Feb 14, 2025

Pull Request Type

  • GitHub Workflow changes
  • Documentation or Wiki changes
  • Build and Dependency changes
  • Runtime changes
    • Render changes
    • Audio changes
    • Input changes
    • Network changes
    • Other changes

Description

Now that SDL3 has a stable release, it's about time we upgrade our main dependency ! This will unlock new features that we could use, such as the GPU API or the Dialog API.

This upgrade was performed using the migration guide and Python renaming script for functions and macros that changed name.

Due to an issue in upstream dbus (which is now required for SDL3) when cross-compiling, I had to create an overlay port inspired by vcpkg#40038.

I also tried to make third-party management more manageable so that developers only have 2 options to get non-vendored dependencies: either use vcpkg or install dependencies themselves so that find_package finds them automatically. There used to be a 3rd option for plog that could use the code from a submodule. For consistency, it was removed as well as the USE_EXTERNAL_PLOG cmake option.

Gamma correction was also removed because SDL3 does not support it.

Copy link
Member

@pzychotic pzychotic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job, really like the removed submodules :)

@Lgt2x Lgt2x mentioned this pull request Feb 15, 2025
13 tasks
@pzychotic
Copy link
Member

Two things I noticed testing on Win 11:

  • The game is a lot darker now and the brightness slider in settings doesn't do anything. Maybe related to the removed gamma correction?!
  • I have a 4K display with 150% display scaling in Windows settings. Previously the game window was scaled accordingly, now it's not. Might be related to SDL3s new high DPI support.

@Lgt2x
Copy link
Member Author

Lgt2x commented Feb 16, 2025

Two things I noticed testing on Win 11:

* The game is a lot darker now and the brightness slider in settings doesn't do anything. Maybe related to the removed gamma correction?!

Definitely related to gamma correction. The SDL functions related to gamma correction did not work great on Linux in my experience, and they were applied to the entire screen, which is less than ideal. This is part of the reason why they were eventually deleted. In my opinion in-game brightness selection should be implemented at the shader level if we want it, or we can let the user configure their monitor settings themselves using the grey box displayed in the brightness settings, and remove the slider (long gone are the CRT days...). I'm unsure currently how to handle this properly.

* I have a 4K display with 150% display scaling in Windows settings. Previously the game window was scaled accordingly, now it's not. Might be related to SDL3s new [high DPI support](https://wiki.libsdl.org/SDL3/README/highdpi).

I did not notice that because I run my monitor at 100% scaling, but it should be fixed now. We're using SDL_GetDisplayContentScale to scale the window according to the display scaling factor.

@Lgt2x
Copy link
Member Author

Lgt2x commented Feb 17, 2025

Gamma correction is now applied by shaders. This is also better solution than using the native SDL function because it is now applied only to the game window and not the whole screen. The setting is now enabled on Unix platforms, and the "apply" button really works. I'm quite satisfied by this new solution. Can you please test again @pzychotic ? :)

Simplify third-party dependency management: either use the installation provided by VCPKG, or the system one. This avoid having too many different sources for a single 3rd party
Using high-DPI support with a scale factor would not scale the game window. We now take the scaling factor into account, so that the Descent3 game window is bigger if the user chooses a bigger scale factor. Also use the SDL_WINDOWPOS_UNDEFINED_DISPAY with display id, fixing the '-display' argument.

Read more here: https://wiki.libsdl.org/SDL3/README/highdpi
Gamma Correction function hhas been removed in SDL3, so do it in shader code instead. This is a better solution because it allows to perform this correction only on the game window, which was not the case for the SDL function.
@pzychotic
Copy link
Member

Gamma correction is now applied by shaders. ...
Really nice solution and definitely better than the old gamma correction. 👍

@pzychotic pzychotic merged commit 3f7c289 into main Feb 17, 2025
10 checks passed
@Lgt2x Lgt2x changed the title Updgrade to SDL3 Upgrade to SDL3 Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants