SDL3 port WIP.

This commit is contained in:
Martín Lucas Golini
2026-03-21 19:06:19 -03:00
parent c201c8bb50
commit 70cec917da
30 changed files with 2852 additions and 21 deletions

View File

@@ -171,7 +171,8 @@ newoption {
trigger = "with-backend",
description = "Select the backend to use for window and input handling.\n\t\t\tIf no backend is selected or if the selected is not installed the script will search for a backend present in the system, and will use it.",
allowed = {
{ "SDL2", "SDL2" }
{ "SDL2", "SDL2" },
{ "SDL3", "SDL3" },
}
}
newoption {
@@ -802,17 +803,47 @@ function add_sdl2()
end
end
function add_sdl3()
print("Using SDL3 backend");
files { "src/eepp/window/backend/SDL3/*.cpp" }
defines { "EE_BACKEND_SDL_ACTIVE", "EE_SDL_VERSION_3" }
if not can_add_static_backend("SDL3") then
if not os.is_real("emscripten") then
table.insert( link_list, get_backend_link_name( "SDL3" ) )
end
else
insert_static_backend( "SDL3" )
end
end
function set_apple_config()
if is_xcode() or _OPTIONS["use-frameworks"] then
linkoptions { "-F /Library/Frameworks" }
buildoptions { "-F /Library/Frameworks" }
includedirs { "/Library/Frameworks/SDL2.framework/Headers" }
if table.contains(backends, "SDL2") then
includedirs { "/Library/Frameworks/SDL2.framework/Headers" }
end
if table.contains(backends, "SDL3") then
includedirs { "/Library/Frameworks/SDL3.framework/Headers" }
end
end
if os.is("macosx") then
defines { "EE_SDL2_FROM_ROOTPATH" }
if table.contains(backends, "SDL2") then
defines { "EE_SDL2_FROM_ROOTPATH" }
end
if table.contains(backends, "SDL3") then
defines { "EE_SDL3_FROM_ROOTPATH" }
end
if not is_xcode() and not _OPTIONS["use-frameworks"] then
local sdl2flags = popen("sdl2-config --cflags"):gsub("\n", "")
buildoptions { sdl2flags }
if table.contains(backends, "SDL2") then
local sdl2flags = popen("sdl2-config --cflags"):gsub("\n", "")
buildoptions { sdl2flags }
end
if table.contains(backends, "SDL3") then
local sdl3flags = popen("sdl3-config --cflags"):gsub("\n", "")
buildoptions { sdl3flags }
end
end
end
end
@@ -890,9 +921,16 @@ function select_backend()
add_sdl2()
end
if backend_is("SDL3", "SDL3") then
print("Selected SDL3")
add_sdl3()
end
-- If the selected backend is not present, try to find one present
if not backend_selected then
if os_findlib("SDL2", "SDL2") then
if os_findlib("SDL3", "SDL3") then
add_sdl3()
elseif os_findlib("SDL2", "SDL2") then
add_sdl2()
else
print("ERROR: Couldnt find any backend. Forced SDL2.")