Skip to content

Conversation

@bearlikelion
Copy link

This pull request upgrades the project from SDL2 to SDL3. This is a major update that brings numerous improvements, new features, and ensures long-term support for the project's core platform and input layer.

Summary of Changes

The entire engine has been migrated to the new SDL3 API. This involved changes to window creation, event handling, input processing, and the rendering backend. The imgui library has also been updated to use its new SDL3 backend.

Detailed Changes

Build System

  • The CMake build system has been updated to locate and link against SDL3 using find_package(SDL3). The old FindSDL*.cmake modules have been removed or updated.
  • The expected SDL3 library and header paths have been updated project-wide.

Core Engine

  • Headers: All SDL header includes have been updated from <SDL.h> to <SDL3/SDL.h>.
  • Initialization and Shutdown: SDL_Init() and SDL_Quit() calls have been updated to reflect changes in SDL3's subsystem management.
  • Error Handling: Functions that previously returned -1 on error now return false. All error handling code has been updated to check for boolean return values.
  • Window and Display:
    • Window creation now uses the new SDL3 functions and flags.
    • Display and monitor handling has been updated to use the new display management API.
    • The way the engine handles window events, such as resizing and focus changes, has been updated to the new SDL3 event system.
  • Input Handling:
    • The input system has been significantly reworked to use the new SDL3 event system.
    • SDL_Scancode and SDL_Keycode usage has been updated.
    • Gamepad and joystick handling now uses the new SDL_Gamepad API, replacing the deprecated SDL_GameController API. This includes updated button and axis mappings.
    • Mouse input, including relative and global mouse state, has been updated.
  • Rendering:
    • The rendering backends (OpenGL, DirectX) have been updated to work with the new SDL3 window and surface management.
    • For OpenGL, the context creation and management has been updated.
    • For DirectX, retrieving the native window handle has been updated to use the new properties system in SDL3.

ImGui

  • The imgui backend has been switched from the SDL2 implementation to the new imgui_impl_sdl3.cpp backend.
  • The imgui rendering backend has been updated to work with the new SDL3 renderer implementations.

How to Test

  1. Build the project: Ensure that the project builds successfully on all supported platforms (Windows, Linux, macOS).
  2. Run the game: Start the game and ensure that it runs without crashing.
  3. Check windowing:
    • Verify that the game window can be resized, minimized, and maximized.
    • Test fullscreen and windowed modes.
    • Ensure that the game correctly handles focus changes (e.g., alt-tabbing).
  4. Check input:
    • Test all keyboard and mouse inputs in the game and in the UI.
    • Verify that gamepads and joysticks are correctly detected and that all buttons and axes are mapped correctly.
  5. Check UI:
    • Open all UI screens and ensure that they are rendered correctly and that all input works as expected.
    • Pay special attention to text input fields and any UI elements that use special keyboard shortcuts.
  6. Check for regressions: Play through a few levels of the game and look for any visual or functional regressions compared to the previous version.

@Xottab-DUTY
Copy link
Member

We had a PR with SDL3 update in 2024 (#1672). At that moment we were supporting platforms that weren't supporting SDL3, we actually had players that asked us to not update to SDL3, so I asked the author if we can support both SDL2 and SDL3, and it was decided to close the PR to keep the code clean.

My opinion here is that we really should implement all kinds of prebuilt binaries (tracked in #1403), including e.g. AppImage, so that players won't need to build the engine themselves everytime and we won't need to hesitate the upgrades.
It's good to ask the team and community regarding this. As a team member, I support this change :)

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

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants