From 9b0662865ed84325decc242419bea8d7c0349b49 Mon Sep 17 00:00:00 2001 From: Ville Lindholm Date: Thu, 28 May 2026 21:23:08 +0300 Subject: [PATCH] WIP: switch build to SDL 3 (does not compile yet) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is the first commit of the SDL 1.2 -> SDL 3 migration. It lands the build-system change and the include-path rewrites; the code does NOT compile against SDL 3 yet, by design. Stays on this branch until the migration is finished. - CMakeLists.txt: find_package(SDL3 CONFIG) + SDL3::SDL3 / SDL3_image::SDL3_image. Drops the legacy FindSDL machinery. - glSDL.h, sprite.c, glSDL.c, filters.c, gfxengine.cpp, audio.c: rewrite #include "SDL*.h" -> / . Known wall: graphics/glSDL.{c,h} collides with SDL 3's surface API renames (SDL_FreeSurface, SDL_FillRect, SDL_SetColorKey, SDL_SetClipRect, SDL_bool). The next phase deletes the entire glSDL shim and rewrites graphics/ against SDL_Renderer / SDL_Texture. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- CMakeLists.txt | 11 ++++------- graphics/filters.c | 2 +- graphics/gfxengine.cpp | 2 +- graphics/glSDL.c | 2 +- graphics/glSDL.h | 2 +- graphics/sprite.c | 2 +- sound/audio.c | 4 ++-- 7 files changed, 11 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1dcd6a6..c7a3c16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,11 +35,9 @@ check_symbol_exists(_vsnprintf stdio.h HAVE__VSNPRINTF) # --------------------------------------------------------------------------- # Third-party libraries # --------------------------------------------------------------------------- -# This codebase targets SDL 1.2 and SDL_image 1.2. CMake's bundled FindSDL -# / FindSDL_image modules locate these directly; on macOS with Homebrew, -# `brew install sdl12-compat sdl_image` works. -find_package(SDL REQUIRED) -find_package(SDL_image REQUIRED) +# Migrating to SDL 3. Homebrew: `brew install sdl3 sdl3_image`. +find_package(SDL3 CONFIG REQUIRED) +find_package(SDL3_image CONFIG REQUIRED) if(KOBO_ENABLE_OPENGL) find_package(OpenGL) @@ -122,9 +120,8 @@ target_compile_definitions(kobo_deps INTERFACE target_include_directories(kobo_deps INTERFACE ${CMAKE_CURRENT_BINARY_DIR} # for generated aconfig.h ${CMAKE_CURRENT_SOURCE_DIR} # for config.h - ${SDL_INCLUDE_DIR} ) -target_link_libraries(kobo_deps INTERFACE ${SDL_LIBRARY} ${SDL_IMAGE_LIBRARIES}) +target_link_libraries(kobo_deps INTERFACE SDL3::SDL3 SDL3_image::SDL3_image) if(HAVE_OPENGL) target_compile_definitions(kobo_deps INTERFACE HAVE_OPENGL) diff --git a/graphics/filters.c b/graphics/filters.c index 106041e..f1ae9ff 100644 --- a/graphics/filters.c +++ b/graphics/filters.c @@ -23,7 +23,7 @@ #include #include "logger.h" #include "glSDL.h" -#include "SDL_image.h" +#include #include "sprite.h" #include "filters.h" diff --git a/graphics/gfxengine.cpp b/graphics/gfxengine.cpp index c70a4b1..4016d8e 100644 --- a/graphics/gfxengine.cpp +++ b/graphics/gfxengine.cpp @@ -28,7 +28,7 @@ #include "gfxengine.h" #include "filters.h" -#include "SDL_image.h" +#include #include "glSDL.h" #include "sofont.h" #include "window.h" diff --git a/graphics/glSDL.c b/graphics/glSDL.c index 599a1ff..b43e90b 100644 --- a/graphics/glSDL.c +++ b/graphics/glSDL.c @@ -30,7 +30,7 @@ #include #if HAS_SDL_OPENGL_H -#include "SDL_opengl.h" +#include #else #ifdef WIN32 #include diff --git a/graphics/glSDL.h b/graphics/glSDL.h index 7bdf193..f0bbf4a 100644 --- a/graphics/glSDL.h +++ b/graphics/glSDL.h @@ -20,7 +20,7 @@ */ /* We're still using SDL datatypes here - we just add some stuff. */ -#include "SDL.h" +#include /* * Ignore the flag from SDL w/ glSDL backend, since we're going diff --git a/graphics/sprite.c b/graphics/sprite.c index bb3c582..b1b9eb9 100644 --- a/graphics/sprite.c +++ b/graphics/sprite.c @@ -30,7 +30,7 @@ TODO: tables as needed when loading banks. #include #include "logger.h" #include "glSDL.h" -#include "SDL_image.h" +#include #include "sprite.h" #include "filters.h" diff --git a/sound/audio.c b/sound/audio.c index bbdce24..61f7007 100644 --- a/sound/audio.c +++ b/sound/audio.c @@ -45,8 +45,8 @@ #include "audiodev.h" #endif -#include "SDL.h" -#include "SDL_audio.h" +#include +#include #include "logger.h" #include "a_struct.h"