From b397667833eaa0770d78843db18125e210f3f889 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Fri, 25 Nov 2022 16:30:23 -0500
Subject: [PATCH] Some initial fixes to get this compiling. Incomplete!
---
CMakeLists.txt | 4 ++--
src/SDLmain/dummy/SDL_dummy_main.c | 1 -
src/sdl2_compat.c | 21 +++++++--------------
src/sdl3_include_wrapper.h | 4 +++-
src/sdl3_syms.h | 24 ++++++++++++------------
5 files changed, 24 insertions(+), 30 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 591d2f1..43ec4fc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -159,7 +159,7 @@ endif()
#else()
add_library(SDLmain STATIC src/SDLmain/dummy/SDL_dummy_main.c)
#endif()
-target_include_directories(SDLmain PRIVATE "include/SDL")
+target_include_directories(SDLmain PRIVATE "include/SDL2")
if(SDL2TESTS)
if(NOT (WIN32 OR APPLE OR CYGWIN OR HAIKU OR BEOS))
@@ -180,7 +180,7 @@ if(SDL2TESTS)
macro(test_program _NAME _SRCS)
add_executable(${_NAME} ${_SRCS})
- target_include_directories(${_NAME} PRIVATE "include/SDL")
+ target_include_directories(${_NAME} PRIVATE "include/SDL2")
if(MINGW)
target_link_libraries(${_NAME} mingw32 SDLmain SDL)
else()
diff --git a/src/SDLmain/dummy/SDL_dummy_main.c b/src/SDLmain/dummy/SDL_dummy_main.c
index b78d8db..85247ac 100644
--- a/src/SDLmain/dummy/SDL_dummy_main.c
+++ b/src/SDLmain/dummy/SDL_dummy_main.c
@@ -1,7 +1,6 @@
/*
SDL_dummy_main.c, placed in the public domain by Sam Lantinga 3/13/14
*/
-#include "../../SDL_internal.h"
/* Include the SDL main definition header */
#include "SDL_main.h"
diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index 439989c..5c52e34 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -104,6 +104,11 @@ extern "C" {
#define SDL3_zerop(x) SDL3_memset((x), 0, sizeof(*(x)))
#define SDL_ReportAssertion SDL3_ReportAssertion
+
+static SDL_bool WantDebugLogging = SDL_FALSE;
+static Uint32 LinkedSDL3VersionInt = 0;
+
+
/* Obviously we can't use SDL_LoadObject() to load SDL2. :) */
static char loaderror[256];
#if defined(_WIN32)
@@ -293,18 +298,6 @@ SDL2Compat_GetHintBoolean(const char *name, SDL_bool default_value)
return (SDL3_atoi(val) != 0) ? SDL_TRUE : SDL_FALSE;
}
-static float
-SDL2Compat_GetHintFloat(const char *name, float default_value)
-{
- const char *val = SDL2Compat_GetHint(name);
-
- if (!val) {
- return default_value;
- }
-
- return (float) SDL3_atof(val);
-}
-
static void
SDL2Compat_ApplyQuirks(SDL_bool force_x11)
{
@@ -383,8 +376,8 @@ LoadSDL3(void)
if (okay) {
SDL_version v;
SDL3_GetVersion(&v);
- LinkedSDL2VersionInt = SDL_VERSIONNUM(v.major, v.minor, v.patch);
- okay = (LinkedSDL2VersionInt >= SDL3_REQUIRED_VER);
+ LinkedSDL3VersionInt = SDL_VERSIONNUM(v.major, v.minor, v.patch);
+ okay = (LinkedSDL3VersionInt >= SDL3_REQUIRED_VER);
if (!okay) {
sprintf_fn(loaderror, "SDL3 %d.%d.%d library is too old.", v.major, v.minor, v.patch);
} else {
diff --git a/src/sdl3_include_wrapper.h b/src/sdl3_include_wrapper.h
index a75633f..43121ab 100644
--- a/src/sdl3_include_wrapper.h
+++ b/src/sdl3_include_wrapper.h
@@ -910,12 +910,14 @@
#define __BUILDING_SDL2_COMPAT__ 1
#include "SDL.h"
-#include "SDL_syswm.h" /* includes windows.h for _WIN32, os2.h for __OS2__ */
#if !SDL_VERSION_ATLEAST(3,0,0)
#error You need to compile against SDL >= 3.0.0 headers.
#endif
+#include "SDL_syswm.h" /* includes windows.h for _WIN32, os2.h for __OS2__ */
+#include "SDL_vulkan.h"
+
/* Missing SDL_thread.h stuff (see above): */
#if defined(_WIN32)
typedef struct SDL_Thread SDL_Thread;
diff --git a/src/sdl3_syms.h b/src/sdl3_syms.h
index 9df39d0..ef53851 100644
--- a/src/sdl3_syms.h
+++ b/src/sdl3_syms.h
@@ -42,17 +42,17 @@
Also, this file gets included multiple times, don't add #pragma once, etc.
*/
-SDL3_SYM_VARARGS(int,SetError,(SDL_PRINTF_FORMAT_STRING const char *a, ...),(a),return)
-SDL3_SYM_VARARGS(void,Log,(SDL_PRINTF_FORMAT_STRING const char *a, ...),(a),)
-SDL3_SYM_VARARGS(void,LogVerbose,(int a, SDL_PRINTF_FORMAT_STRING const char *b, ...),(a,b),)
-SDL3_SYM_VARARGS(void,LogDebug,(int a, SDL_PRINTF_FORMAT_STRING const char *b, ...),(a,b),)
-SDL3_SYM_VARARGS(void,LogInfo,(int a, SDL_PRINTF_FORMAT_STRING const char *b, ...),(a,b),)
-SDL3_SYM_VARARGS(void,LogWarn,(int a, SDL_PRINTF_FORMAT_STRING const char *b, ...),(a,b),)
-SDL3_SYM_VARARGS(void,LogError,(int a, SDL_PRINTF_FORMAT_STRING const char *b, ...),(a,b),)
-SDL3_SYM_VARARGS(void,LogCritical,(int a, SDL_PRINTF_FORMAT_STRING const char *b, ...),(a,b),)
-SDL3_SYM_VARARGS(void,LogMessage,(int a, SDL_LogPriority b, SDL_PRINTF_FORMAT_STRING const char *c, ...),(a,b,c),)
-SDL3_SYM_VARARGS(int,sscanf,(const char *a, SDL_SCANF_FORMAT_STRING const char *b, ...),(a,b),return)
-SDL3_SYM_VARARGS(int,snprintf,(SDL_OUT_Z_CAP(b) char *a, size_t b, SDL_PRINTF_FORMAT_STRING const char *c, ...),(a,b,c),return)
+SDL3_SYM_VARARGS(int,SetError,(SDL_PRINTF_FORMAT_STRING const char *a, ...))
+SDL3_SYM_VARARGS(void,Log,(SDL_PRINTF_FORMAT_STRING const char *a, ...))
+SDL3_SYM_VARARGS(void,LogVerbose,(int a, SDL_PRINTF_FORMAT_STRING const char *b, ...))
+SDL3_SYM_VARARGS(void,LogDebug,(int a, SDL_PRINTF_FORMAT_STRING const char *b, ...))
+SDL3_SYM_VARARGS(void,LogInfo,(int a, SDL_PRINTF_FORMAT_STRING const char *b, ...))
+SDL3_SYM_VARARGS(void,LogWarn,(int a, SDL_PRINTF_FORMAT_STRING const char *b, ...))
+SDL3_SYM_VARARGS(void,LogError,(int a, SDL_PRINTF_FORMAT_STRING const char *b, ...))
+SDL3_SYM_VARARGS(void,LogCritical,(int a, SDL_PRINTF_FORMAT_STRING const char *b, ...))
+SDL3_SYM_VARARGS(void,LogMessage,(int a, SDL_LogPriority b, SDL_PRINTF_FORMAT_STRING const char *c, ...))
+SDL3_SYM_VARARGS(int,sscanf,(const char *a, SDL_SCANF_FORMAT_STRING const char *b, ...))
+SDL3_SYM_VARARGS(int,snprintf,(SDL_OUT_Z_CAP(b) char *a, size_t b, SDL_PRINTF_FORMAT_STRING const char *c, ...))
#if defined(__WIN32__) || defined(__GDK__)
SDL3_SYM_PASSTHROUGH(SDL_Thread*,CreateThread,(SDL_ThreadFunction a, const char *b, void *c, pfnSDL_CurrentBeginThread d, pfnSDL_CurrentEndThread e),(a,b,c,d,e),return)
@@ -886,7 +886,7 @@ SDL3_SYM_PASSTHROUGH(void*,GetTextureUserData,(SDL_Texture *a),(a),return)
SDL3_SYM_PASSTHROUGH(int,RenderGeometry,(SDL_Renderer *a, SDL_Texture *b, const SDL_Vertex *c, int d, const int *e, int f),(a,b,c,d,e,f),return)
SDL3_SYM_PASSTHROUGH(int,RenderGeometryRaw,(SDL_Renderer *a, SDL_Texture *b, const float *c, int d, const SDL_Color *e, int f, const float *g, int h, int i, const void *j, int k, int l),(a,b,c,d,e,f,g,h,i,j,k,l),return)
SDL3_SYM_PASSTHROUGH(int,RenderSetVSync,(SDL_Renderer *a, int b),(a,b),return)
-SDL3_SYM_VARARGS(int,asprintf,(char **a, SDL_PRINTF_FORMAT_STRING const char *b, ...),(a,b),return)
+SDL3_SYM_VARARGS(int,asprintf,(char **a, SDL_PRINTF_FORMAT_STRING const char *b, ...))
SDL3_SYM_PASSTHROUGH(int,vasprintf,(char **a, const char *b, va_list c),(a,b,c),return)
SDL3_SYM_PASSTHROUGH(void*,GetWindowICCProfile,(SDL_Window *a, size_t *b),(a,b),return)
SDL3_SYM_PASSTHROUGH(Uint64,GetTicks64,(void),(),return)