mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-15 20:01:15 +00:00
cleanup & fix oversight
seems sdl2-compat doesn't translate the SDL_GetPixelFormatForMasks behaviour 1 to 1 :P
This commit is contained in:
parent
333867eb38
commit
e0f1336a52
42
3rdparty/CMakeLists.txt
vendored
42
3rdparty/CMakeLists.txt
vendored
@ -75,13 +75,12 @@ if(ISLE_DEBUG)
|
||||
)
|
||||
else()
|
||||
target_sources(imgui PRIVATE
|
||||
${imgui_SOURCE_DIR}/backends/imgui_impl_sdl3.cpp
|
||||
${imgui_SOURCE_DIR}/backends/imgui_impl_sdlrenderer3.cpp
|
||||
${imgui_SOURCE_DIR}/backends/imgui_impl_sdl3.cpp
|
||||
${imgui_SOURCE_DIR}/backends/imgui_impl_sdlrenderer3.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
target_include_directories(imgui PUBLIC ${imgui_SOURCE_DIR})
|
||||
target_link_libraries(imgui PUBLIC SDL3::Headers)
|
||||
target_link_libraries(imgui PRIVATE SDL3::SDL3)
|
||||
set_property(TARGET imgui PROPERTY CXX_CLANG_TIDY "")
|
||||
endif()
|
||||
@ -105,40 +104,3 @@ add_library(libweaver STATIC
|
||||
${libweaver_SOURCE_DIR}/lib/sitypes.cpp
|
||||
)
|
||||
target_include_directories(libweaver PUBLIC ${libweaver_SOURCE_DIR}/lib)
|
||||
|
||||
if(USE_SDL2)
|
||||
if(DOWNLOAD_DEPENDENCIES)
|
||||
# include(FetchContent)
|
||||
# FetchContent_Declare(
|
||||
# SDL2
|
||||
# GIT_REPOSITORY "https://github.com/libsdl-org/SDL.git"
|
||||
# GIT_TAG 5d249570393f7a37e037abf22cd6012a4cc56a71
|
||||
# EXCLUDE_FROM_ALL
|
||||
# )
|
||||
# FetchContent_MakeAvailable(SDL2)
|
||||
# Find SDL2 normally
|
||||
find_package(SDL2 REQUIRED)
|
||||
|
||||
endif()
|
||||
|
||||
file(GLOB SDL2_HEADERS "${SDL2_INCLUDE_DIR}/*.h")
|
||||
foreach(header IN LISTS SDL2_HEADERS)
|
||||
get_filename_component(fname ${header} NAME)
|
||||
configure_file(${header} ${CMAKE_CURRENT_BINARY_DIR}/sdl3-shim/SDL3/${fname} COPYONLY)
|
||||
endforeach()
|
||||
|
||||
|
||||
add_library(SDL3_shim STATIC
|
||||
sdl3-shim/main.cpp
|
||||
)
|
||||
target_link_libraries(SDL3_shim PRIVATE SDL2::SDL2)
|
||||
target_include_directories(SDL3_shim PUBLIC
|
||||
${SDL2_INCLUDE_DIRS}
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/sdl3-shim"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/sdl3-shim"
|
||||
)
|
||||
|
||||
add_library(SDL3::SDL3 ALIAS SDL3_shim)
|
||||
add_library(SDL3::Headers ALIAS SDL3_shim)
|
||||
|
||||
endif()
|
||||
|
||||
18
3rdparty/sdl3-shim/CMakeLists.txt
vendored
Normal file
18
3rdparty/sdl3-shim/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
file(GLOB SDL2_HEADERS "${SDL2_INCLUDE_DIR}/*.h")
|
||||
foreach(header IN LISTS SDL2_HEADERS)
|
||||
get_filename_component(fname ${header} NAME)
|
||||
configure_file(${header} ${CMAKE_CURRENT_BINARY_DIR}/SDL3/${fname} COPYONLY)
|
||||
endforeach()
|
||||
|
||||
add_library(SDL3_shim STATIC
|
||||
main.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(SDL3_shim PUBLIC SDL2::SDL2)
|
||||
target_include_directories(SDL3_shim PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}"
|
||||
)
|
||||
|
||||
add_library(SDL3::SDL3 ALIAS SDL3_shim)
|
||||
add_library(SDL3::Headers ALIAS SDL3_shim)
|
||||
1
3rdparty/sdl3-shim/SDL3/SDL.h
vendored
1
3rdparty/sdl3-shim/SDL3/SDL.h
vendored
@ -7,6 +7,7 @@
|
||||
#include <SDL2/SDL_keyboard.h>
|
||||
#include <SDL2/SDL_video.h>
|
||||
#include <SDL2/SDL_mouse.h>
|
||||
#include <SDL2/SDL_version.h>
|
||||
|
||||
#include "SDL_audio.h"
|
||||
#include "SDL_events.h"
|
||||
|
||||
1
3rdparty/sdl3-shim/SDL3/SDL_audio.h
vendored
1
3rdparty/sdl3-shim/SDL3/SDL_audio.h
vendored
@ -2,6 +2,7 @@
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
|
||||
|
||||
12
3rdparty/sdl3-shim/SDL3/SDL_pixels.h
vendored
12
3rdparty/sdl3-shim/SDL3/SDL_pixels.h
vendored
@ -32,6 +32,16 @@ static bool operator!=(SDL_PixelFormatDetails* lhs, SDL_PixelFormatEnum rhs)
|
||||
#define SDL_CreatePalette SDL_AllocPalette
|
||||
#define SDL_DestroyPalette SDL_FreePalette
|
||||
|
||||
#define SDL_GetPixelFormatForMasks (SDL_PixelFormat)SDL_MasksToPixelFormatEnum
|
||||
// #define SDL_GetPixelFormatForMasks (SDL_PixelFormat)SDL_MasksToPixelFormatEnum
|
||||
inline SDL_PixelFormatEnum SDL_GetPixelFormatForMasks(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
|
||||
{
|
||||
// SDL2 checks if Rmask == 0; SDL3 just returns INDEX8 if Rmask doesn't match
|
||||
// https://github.com/libsdl-org/SDL/blob/66d87bf0e1e29377b398d3c567e1ab3590760d8c/src/video/SDL_pixels.c#L310C5-L321C13
|
||||
// https://github.com/libsdl-org/SDL/blob/3669920fddcc418c5f9aca97e77a3f380308d9c0/src/video/SDL_pixels.c#L411-L418C16
|
||||
if (bpp == 8 && Rmask != 0xE0) {
|
||||
return SDL_PIXELFORMAT_INDEX8;
|
||||
}
|
||||
return static_cast<SDL_PixelFormatEnum>(SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask));
|
||||
}
|
||||
|
||||
#define SDL_GetSurfacePalette(surface) (nullptr)
|
||||
|
||||
@ -60,12 +60,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" CACHE PATH "Directory w
|
||||
set(ISLE_EMSCRIPTEN_HOST "" CACHE STRING "Host URL for Emscripten streaming (e.g., https://test.com)")
|
||||
cmake_dependent_option(BUILD_SHARED_LIBS "Build lego1 as a shared library" ON "NOT EMSCRIPTEN" OFF)
|
||||
|
||||
if(USE_SDL2)
|
||||
add_compile_definitions(SDL_MAJOR_VERSION=2)
|
||||
else()
|
||||
add_compile_definitions(SDL_MAJOR_VERSION=3)
|
||||
endif()
|
||||
|
||||
message(STATUS "Isle app: ${ISLE_BUILD_APP}")
|
||||
message(STATUS "Config app: ${ISLE_BUILD_CONFIG}")
|
||||
message(STATUS "Internal DirectX5 SDK: ${ISLE_USE_DX5}")
|
||||
@ -82,27 +76,40 @@ if (DOWNLOAD_DEPENDENCIES)
|
||||
include(FetchContent)
|
||||
|
||||
if(NOT USE_SDL2)
|
||||
if(ANDROID)
|
||||
# Built by Gradle
|
||||
find_package(SDL3 REQUIRED CONFIG COMPONENTS Shared)
|
||||
else()
|
||||
if (WINDOWS_STORE)
|
||||
FetchContent_Declare(
|
||||
SDL3
|
||||
GIT_REPOSITORY "https://github.com/Helloyunho/SDL3-uwp.git"
|
||||
GIT_TAG "main"
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
if(ANDROID)
|
||||
# Built by Gradle
|
||||
find_package(SDL3 REQUIRED CONFIG COMPONENTS Shared)
|
||||
else()
|
||||
FetchContent_Declare(
|
||||
SDL3
|
||||
GIT_REPOSITORY "https://github.com/libsdl-org/SDL.git"
|
||||
GIT_TAG "main"
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
if (WINDOWS_STORE)
|
||||
FetchContent_Declare(
|
||||
SDL3
|
||||
GIT_REPOSITORY "https://github.com/Helloyunho/SDL3-uwp.git"
|
||||
GIT_TAG "main"
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
else()
|
||||
FetchContent_Declare(
|
||||
SDL3
|
||||
GIT_REPOSITORY "https://github.com/libsdl-org/SDL.git"
|
||||
GIT_TAG "main"
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
endif()
|
||||
FetchContent_MakeAvailable(SDL3)
|
||||
endif()
|
||||
FetchContent_MakeAvailable(SDL3)
|
||||
endif()
|
||||
else()
|
||||
FetchContent_Declare(
|
||||
SDL2
|
||||
GIT_REPOSITORY "https://github.com/libsdl-org/SDL.git"
|
||||
GIT_TAG SDL2
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
# set(SDL_STATIC ON CACHE BOOL "" FORCE)
|
||||
# set(SDL_SHARED OFF CACHE BOOL "" FORCE)
|
||||
FetchContent_MakeAvailable(SDL2)
|
||||
|
||||
set(SDL2_INCLUDE_DIR ${SDL2_SOURCE_DIR}/include)
|
||||
add_subdirectory(3rdparty/sdl3-shim SYSTEM)
|
||||
endif()
|
||||
|
||||
FetchContent_Declare(
|
||||
@ -121,7 +128,12 @@ else()
|
||||
# find_package looks for already-installed system packages.
|
||||
# Configure with `-DCMAKE_PREFIX_PATH="/path/to/package1;/path/to/package2"`
|
||||
# to add search paths.
|
||||
find_package(SDL3 CONFIG REQUIRED)
|
||||
if(NOT USE_SDL2)
|
||||
find_package(SDL3 CONFIG REQUIRED)
|
||||
else()
|
||||
find_package(SDL2 CONFIG REQUIRED)
|
||||
add_subdirectory(3rdparty/sdl3-shim SYSTEM)
|
||||
endif()
|
||||
|
||||
find_package(iniparser REQUIRED CONFIG COMPONENTS shared)
|
||||
target_link_libraries(Isle::iniparser INTERFACE iniparser-shared)
|
||||
|
||||
@ -18,6 +18,12 @@
|
||||
#else
|
||||
#include <backends/imgui_impl_sdl2.h>
|
||||
#include <backends/imgui_impl_sdlrenderer2.h>
|
||||
#define ImGui_ImplSDL3_InitForSDLRenderer ImGui_ImplSDL2_InitForSDLRenderer
|
||||
#define ImGui_ImplSDLRenderer3_Init ImGui_ImplSDLRenderer2_Init
|
||||
#define ImGui_ImplSDL3_ProcessEvent ImGui_ImplSDL2_ProcessEvent
|
||||
#define ImGui_ImplSDLRenderer3_NewFrame ImGui_ImplSDLRenderer2_NewFrame
|
||||
#define ImGui_ImplSDL3_NewFrame ImGui_ImplSDL2_NewFrame
|
||||
#define ImGui_ImplSDLRenderer3_RenderDrawData ImGui_ImplSDLRenderer2_RenderDrawData
|
||||
#endif
|
||||
#include <imgui.h>
|
||||
|
||||
@ -181,11 +187,7 @@ void IsleDebug_Init()
|
||||
ImGui::CreateContext();
|
||||
ImGui::StyleColorsDark();
|
||||
|
||||
#if SDL_MAJOR_VERSION >= 3
|
||||
if (!ImGui_ImplSDL3_InitForSDLRenderer(g_debugWindow, g_debugRenderer)) {
|
||||
#else
|
||||
if (!ImGui_ImplSDL2_InitForSDLRenderer(g_debugWindow, g_debugRenderer)) {
|
||||
#endif
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "ImGui_ImplSDL3_InitForSDLRenderer failed");
|
||||
g_debugEnabled = false;
|
||||
break;
|
||||
@ -197,11 +199,7 @@ void IsleDebug_Init()
|
||||
#else
|
||||
SDL_SetTextureScaleMode(g_videoPalette, SDL_SCALEMODE_NEAREST);
|
||||
#endif
|
||||
#if SDL_MAJOR_VERSION >= 3
|
||||
if (!ImGui_ImplSDLRenderer3_Init(g_debugRenderer)) {
|
||||
#else
|
||||
if (!ImGui_ImplSDLRenderer2_Init(g_debugRenderer)) {
|
||||
#endif
|
||||
g_debugEnabled = false;
|
||||
break;
|
||||
}
|
||||
@ -262,11 +260,7 @@ bool IsleDebug_Event(SDL_Event* event)
|
||||
if (SDL_GetWindowFromEvent(event) != g_debugWindow) {
|
||||
return false;
|
||||
}
|
||||
#if SDL_MAJOR_VERSION >= 3
|
||||
ImGui_ImplSDL3_ProcessEvent(event);
|
||||
#else
|
||||
ImGui_ImplSDL2_ProcessEvent(event);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -276,13 +270,9 @@ void IsleDebug_Render()
|
||||
return;
|
||||
}
|
||||
const ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
|
||||
#if SDL_MAJOR_VERSION >= 3
|
||||
|
||||
ImGui_ImplSDLRenderer3_NewFrame();
|
||||
ImGui_ImplSDL3_NewFrame();
|
||||
#else
|
||||
ImGui_ImplSDLRenderer2_NewFrame();
|
||||
ImGui_ImplSDL2_NewFrame();
|
||||
#endif
|
||||
ImGui::NewFrame();
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
{
|
||||
@ -375,11 +365,7 @@ void IsleDebug_Render()
|
||||
(Uint8) (clear_color.z * 255),
|
||||
(Uint8) (clear_color.w * 255)
|
||||
);
|
||||
#if SDL_MAJOR_VERSION >= 3
|
||||
ImGui_ImplSDLRenderer3_RenderDrawData(ImGui::GetDrawData(), g_debugRenderer);
|
||||
#else
|
||||
ImGui_ImplSDLRenderer2_RenderDrawData(ImGui::GetDrawData(), g_debugRenderer);
|
||||
#endif
|
||||
SDL_RenderPresent(g_debugRenderer);
|
||||
}
|
||||
|
||||
|
||||
@ -34,6 +34,7 @@
|
||||
#include <SDL3/SDL_events.h>
|
||||
#include <SDL3/SDL_process.h>
|
||||
#include <SDL3/SDL_stdinc.h>
|
||||
#include <SDL3/SDL_version.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <vec.h>
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
#include "roi/legoroi.h"
|
||||
|
||||
#include <SDL3/SDL_log.h>
|
||||
#include <SDL3/SDL_version.h>
|
||||
|
||||
DECOMP_SIZE_ASSERT(LegoInputManager, 0x338)
|
||||
DECOMP_SIZE_ASSERT(LegoNotifyList, 0x18)
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include "omni/include/mxvideoparam.h"
|
||||
|
||||
#include <SDL3/SDL_log.h>
|
||||
#include <SDL3/SDL_version.h>
|
||||
#include <assert.h>
|
||||
#include <miniwin/miniwind3d.h>
|
||||
#include <stdio.h> // for vsprintf
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include "decomp.h"
|
||||
|
||||
#include <SDL3/SDL_timer.h>
|
||||
#include <SDL3/SDL_version.h>
|
||||
|
||||
DECOMP_SIZE_ASSERT(MxThread, 0x1c)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user