sdl2-compat: Updated after SDL_RenderGeometryRaw() switched back to SDL_FColor again

From c3ae3e049bd4bed0645ca7676603c513b9a7d0b4 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Sun, 30 Jun 2024 10:40:40 +0300
Subject: [PATCH] Updated after SDL_RenderGeometryRaw() switched back to
 SDL_FColor again

This basically reverts commit d079b3951e90b1d0ca142093046d4b7983d4d61a.
---
 src/sdl2_compat.c          | 28 +++++++++++++++++++++++++++-
 src/sdl3_include_wrapper.h | 10 +++++-----
 src/sdl3_syms.h            |  2 +-
 3 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index fed3bd6..0b3c85e 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -4693,7 +4693,33 @@ SDL_RenderGeometry(SDL_Renderer *renderer, SDL_Texture *texture, const SDL2_Vert
 SDL_DECLSPEC int SDLCALL
 SDL_RenderGeometryRaw(SDL_Renderer *renderer, SDL_Texture *texture, const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, int num_vertices, const void *indices, int num_indices, int size_indices)
 {
-    const int retval = SDL3_RenderGeometryRaw(renderer, texture, xy, xy_stride, color, color_stride, uv, uv_stride, num_vertices, indices, num_indices, size_indices);
+    int i, retval, isstack;
+    const char *color2 = (const char *) color;
+    SDL_FColor *color3;
+
+    if (num_vertices <= 0) {
+        return SDL3_InvalidParamError("num_vertices");
+    }
+    if (!color) {
+        return SDL3_InvalidParamError("color");
+    }
+
+    color3 = (SDL_FColor *) SDL3_small_alloc(SDL_FColor, num_vertices, &isstack);
+    if (!color3) {
+        return SDL3_OutOfMemory();
+    }
+    for (i = 0; i < num_vertices; ++i) {
+        color3[i].r = color->r / 255.0f;
+        color3[i].g = color->g / 255.0f;
+        color3[i].b = color->b / 255.0f;
+        color3[i].a = color->a / 255.0f;
+        color2 += color_stride;
+        color = (const SDL_Color *) color2;
+    }
+
+    color_stride = sizeof(SDL_FColor);
+    retval = SDL3_RenderGeometryRaw(renderer, texture, xy, xy_stride, color3, color_stride, uv, uv_stride, num_vertices, indices, num_indices, size_indices);
+    SDL3_small_free(color3, isstack);
     return retval < 0 ? retval : FlushRendererIfNotBatching(renderer);
 }
 
diff --git a/src/sdl3_include_wrapper.h b/src/sdl3_include_wrapper.h
index b3e6070..47413b2 100644
--- a/src/sdl3_include_wrapper.h
+++ b/src/sdl3_include_wrapper.h
@@ -425,6 +425,7 @@
 #define SDL_GetRenderDrawColorFloat IGNORE_THIS_VERSION_OF_SDL_GetRenderDrawColorFloat
 #define SDL_GetRenderDriver IGNORE_THIS_VERSION_OF_SDL_GetRenderDriver
 #define SDL_GetRenderLogicalPresentation IGNORE_THIS_VERSION_OF_SDL_GetRenderLogicalPresentation
+#define SDL_GetRenderLogicalPresentationRect IGNORE_THIS_VERSION_OF_SDL_GetRenderLogicalPresentationRect
 #define SDL_GetRenderMetalCommandEncoder IGNORE_THIS_VERSION_OF_SDL_GetRenderMetalCommandEncoder
 #define SDL_GetRenderMetalLayer IGNORE_THIS_VERSION_OF_SDL_GetRenderMetalLayer
 #define SDL_GetRenderOutputSize IGNORE_THIS_VERSION_OF_SDL_GetRenderOutputSize
@@ -677,7 +678,6 @@
 #define SDL_RenderFillRects IGNORE_THIS_VERSION_OF_SDL_RenderFillRects
 #define SDL_RenderGeometry IGNORE_THIS_VERSION_OF_SDL_RenderGeometry
 #define SDL_RenderGeometryRaw IGNORE_THIS_VERSION_OF_SDL_RenderGeometryRaw
-#define SDL_RenderGeometryRawFloat IGNORE_THIS_VERSION_OF_SDL_RenderGeometryRawFloat
 #define SDL_RenderLine IGNORE_THIS_VERSION_OF_SDL_RenderLine
 #define SDL_RenderLines IGNORE_THIS_VERSION_OF_SDL_RenderLines
 #define SDL_RenderPoint IGNORE_THIS_VERSION_OF_SDL_RenderPoint
@@ -2660,6 +2660,10 @@
 #undef SDL_GetRenderLogicalPresentation
 #endif
 
+#ifdef SDL_GetRenderLogicalPresentationRect
+#undef SDL_GetRenderLogicalPresentationRect
+#endif
+
 #ifdef SDL_GetRenderMetalCommandEncoder
 #undef SDL_GetRenderMetalCommandEncoder
 #endif
@@ -3668,10 +3672,6 @@
 #undef SDL_RenderGeometryRaw
 #endif
 
-#ifdef SDL_RenderGeometryRawFloat
-#undef SDL_RenderGeometryRawFloat
-#endif
-
 #ifdef SDL_RenderLine
 #undef SDL_RenderLine
 #endif
diff --git a/src/sdl3_syms.h b/src/sdl3_syms.h
index 744a574..1a030d1 100644
--- a/src/sdl3_syms.h
+++ b/src/sdl3_syms.h
@@ -688,7 +688,7 @@ SDL3_SYM_PASSTHROUGH(int,FlashWindow,(SDL_Window *a, SDL_FlashOperation b),(a,b)
 SDL3_SYM_RENAMED(int,GameControllerSendEffect,SendGamepadEffect,(SDL_GameController *a, const void *b, int c),(a,b,c),return)
 SDL3_SYM_RENAMED(int,JoystickSendEffect,SendJoystickEffect,(SDL_Joystick *a, const void *b, int c),(a,b,c),return)
 SDL3_SYM_RENAMED(float,GameControllerGetSensorDataRate,GetGamepadSensorDataRate,(SDL_GameController *a, SDL_SensorType b),(a,b),return)
-SDL3_SYM(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(int,RenderGeometryRaw,(SDL_Renderer *a, SDL_Texture *b, const float *c, int d, const SDL_FColor *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_RENAMED(int,RenderSetVSync,SetRenderVSync,(SDL_Renderer *a, int 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)