From 7c117e147cc14c25b7e4d8e93fb7e2bc16499a0f Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 6 Mar 2024 08:48:12 +0100 Subject: [PATCH] changed function to create native SDL surface --- src/libgame/sdl.c | 32 +++++++++++++++----------------- src/libgame/sdl.h | 2 +- src/libgame/system.c | 2 +- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index dce24936..e60d760d 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -468,6 +468,21 @@ boolean SDLSetNativeSurface(SDL_Surface **surface) return TRUE; } +SDL_Surface *SDLCreateNativeSurface(int width, int height, int depth) +{ + if (program.headless) + return NULL; + + SDL_Surface *surface = SDL_CreateRGBSurface(SURFACE_FLAGS, width, height, depth, 0,0,0, 0); + + if (surface == NULL) + Fail("SDL_CreateRGBSurface() failed: %s", SDL_GetError()); + + SDLSetNativeSurface(&surface); + + return surface; +} + static SDL_Texture *SDLCreateTextureFromSurface(SDL_Surface *surface) { if (program.headless) @@ -980,23 +995,6 @@ void SDLRedrawWindow(void) UpdateScreen_WithoutFrameDelay(NULL); } -void SDLCreateBitmapContent(Bitmap *bitmap, int width, int height, - int depth) -{ - if (program.headless) - return; - - SDL_Surface *surface = - SDL_CreateRGBSurface(SURFACE_FLAGS, width, height, depth, 0,0,0, 0); - - if (surface == NULL) - Fail("SDL_CreateRGBSurface() failed: %s", SDL_GetError()); - - SDLSetNativeSurface(&surface); - - bitmap->surface = surface; -} - void SDLFreeBitmapPointers(Bitmap *bitmap) { if (bitmap->surface) diff --git a/src/libgame/sdl.h b/src/libgame/sdl.h index 05f99982..3e742394 100644 --- a/src/libgame/sdl.h +++ b/src/libgame/sdl.h @@ -399,6 +399,7 @@ void SDLSetAlpha(SDL_Surface *, boolean, int); const char *SDLGetRendererName(void); boolean SDLSetNativeSurface(SDL_Surface **); SDL_Surface *SDLGetNativeSurface(SDL_Surface *); +SDL_Surface *SDLCreateNativeSurface(int, int, int); void SDLCreateBitmapTextures(Bitmap *); void SDLFreeBitmapTextures(Bitmap *); @@ -420,7 +421,6 @@ void SDLLimitScreenUpdates(boolean); void SDLInitVideoDisplay(void); void SDLInitVideoBuffer(boolean); boolean SDLSetVideoMode(boolean); -void SDLCreateBitmapContent(Bitmap *, int, int, int); void SDLFreeBitmapPointers(Bitmap *); void SDLBlitSurface(SDL_Surface *, SDL_Surface *, int, int, int, int, int, int); void SDLCopyArea(Bitmap *, Bitmap *, int, int, int, int, int, int, int); diff --git a/src/libgame/system.c b/src/libgame/system.c index e83df10b..37fe3a77 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -624,7 +624,7 @@ Bitmap *CreateBitmap(int width, int height, int depth) int real_height = MAX(1, height); // prevent zero bitmap height int real_depth = GetRealDepth(depth); - SDLCreateBitmapContent(new_bitmap, real_width, real_height, real_depth); + new_bitmap->surface = SDLCreateNativeSurface(real_width, real_height, real_depth); new_bitmap->width = real_width; new_bitmap->height = real_height; -- 2.34.1