From 5b44fe79758a4919d3efcb46cc5b12eba5beda0c Mon Sep 17 00:00:00 2001 From: meowtech Date: Mon, 30 Mar 2026 19:28:35 +0000 Subject: [PATCH] implementation for older SDL functions to use later --- CMakeLists.txt | 13 +++++++++++++ src/oldimpls/include.h | 1 + src/oldimpls/sdl/include.h | 11 +++++++++++ src/oldimpls/sdl/rgb-surfaces.cpp | 26 ++++++++++++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 src/oldimpls/include.h create mode 100644 src/oldimpls/sdl/include.h create mode 100644 src/oldimpls/sdl/rgb-surfaces.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index f7c886b..bae866c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,17 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) ## Setup main source ## +# oldimpls dir stuff +set(OLDIMPLS_HEADERS + src/oldimpls/include.h + src/oldimpls/sdl/include.h +) + +set(OLDIMPLS_SOURCE + src/oldimpls/sdl/rgb-surfaces.cpp +) + +# main stuff set(MAIN_HEADERS src/quadarray.h src/audio.h @@ -74,6 +85,7 @@ set(MAIN_HEADERS chromasdk/RzErrors.h chromasdk/ChromaApi.h src/i18n.h + ${OLDIMPLS_HEADERS} ) set(MAIN_SOURCE @@ -116,6 +128,7 @@ set(MAIN_SOURCE src/oneshot.cpp src/screen.cpp src/i18n.cpp + ${OLDIMPLS_SOURCE} ) if(WIN32) diff --git a/src/oldimpls/include.h b/src/oldimpls/include.h new file mode 100644 index 0000000..c0208dc --- /dev/null +++ b/src/oldimpls/include.h @@ -0,0 +1 @@ +#include "sdl/include.h" \ No newline at end of file diff --git a/src/oldimpls/sdl/include.h b/src/oldimpls/sdl/include.h new file mode 100644 index 0000000..b935747 --- /dev/null +++ b/src/oldimpls/sdl/include.h @@ -0,0 +1,11 @@ +#ifndef _OLDIMPLS_SDL_INCLUDE_H +#define _OLDIMPLS_SDL_INCLUDE_H + +#include + +static SDL_Surface *SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); +static SDL_Surface *SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth, Uint32 format); +static SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); +static SDL_Surface *SDL_CreateRGBSurfaceWithFormatFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 format); + +#endif \ No newline at end of file diff --git a/src/oldimpls/sdl/rgb-surfaces.cpp b/src/oldimpls/sdl/rgb-surfaces.cpp new file mode 100644 index 0000000..fdcda18 --- /dev/null +++ b/src/oldimpls/sdl/rgb-surfaces.cpp @@ -0,0 +1,26 @@ +#include "include.h" + +// taken from: https://wiki.libsdl.org/SDL3/README-migration#sdl_surfaceh + +static SDL_Surface *SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) +{ + return SDL_CreateSurface(width, height, + SDL_GetPixelFormatForMasks(depth, Rmask, Gmask, Bmask, Amask)); +} + +static SDL_Surface *SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth, Uint32 format) +{ + return SDL_CreateSurface(width, height, (SDL_PixelFormat)format); +} + +static SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) +{ + return SDL_CreateSurfaceFrom(width, height, + SDL_GetPixelFormatForMasks(depth, Rmask, Gmask, Bmask, Amask), + pixels, pitch); +} + +static SDL_Surface *SDL_CreateRGBSurfaceWithFormatFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 format) +{ + return SDL_CreateSurfaceFrom(width, height, (SDL_PixelFormat)format, pixels, pitch); +} \ No newline at end of file