improved error tolerance of SDL native surface conversion
[rocksndiamonds.git] / src / libgame / sdl.c
index 12b39d865e701d9c2bcc64026247c5f3a6630bd7..e7e985052cb7e9f7b8ebd88f4863620e1b939514 100644 (file)
@@ -207,11 +207,13 @@ boolean SDLSetNativeSurface(SDL_Surface **surface)
 
 SDL_Surface *SDLGetNativeSurface(SDL_Surface *surface)
 {
-  if (surface == NULL ||
-      backbuffer == NULL ||
-      backbuffer->surface == NULL)
+  if (surface == NULL)
     return NULL;
 
+  if (backbuffer == NULL ||
+      backbuffer->surface == NULL)
+    return SDL_ConvertSurface(surface, surface->format, 0);
+
   return SDL_ConvertSurface(surface, backbuffer->surface->format, 0);
 }
 
@@ -1338,7 +1340,7 @@ Pixel SDLGetPixel(Bitmap *src_bitmap, int x, int y)
 
 /* ========================================================================= */
 /* The following functions were taken from the SGE library                   */
-/* (SDL Graphics Extension Library) by Anders Lindström                      */
+/* (SDL Graphics Extension Library) by Anders Lindström                      */
 /* http://www.etek.chalmers.se/~e8cal1/sge/index.html                        */
 /* ========================================================================= */