changed function to create native SDL surface
authorHolger Schemel <info@artsoft.org>
Wed, 6 Mar 2024 07:48:12 +0000 (08:48 +0100)
committerHolger Schemel <info@artsoft.org>
Wed, 6 Mar 2024 07:48:52 +0000 (08:48 +0100)
src/libgame/sdl.c
src/libgame/sdl.h
src/libgame/system.c

index dce249365e940efd5b1e9a43d6462904d31fe240..e60d760d6265eab0a93499945ef319ee5735ef50 100644 (file)
@@ -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)
index 05f99982809016f1e5e374c3e64809d973ccad98..3e742394ffffc87e285c8e38c3189927d684642b 100644 (file)
@@ -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);
index e83df10bb1250a83e405380cd3189c77d8006bd4..37fe3a77cab0821c1bd30d4c8a5f07548aec3125 100644 (file)
@@ -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;