DEADSOFTWARE

sdl2: fix building with sdl2 on linux
[flatwaifu.git] / src / sdl2 / main.c
index dd5b8d43b2d16947a79291f66e1dc57d9fa9c38f..fc50b90823a2899c36767640429e7cd64334f0c1 100644 (file)
@@ -1,4 +1,4 @@
-#include <SDL.h>
+#include "SDL.h"
 #include <stdio.h>
 #include <stdarg.h>
 #include <stdlib.h> // srand exit
@@ -127,11 +127,13 @@ static int Y_resize_window (int w, int h, int fullscreen) {
   assert(h > 0);
   assert(window != NULL);
   if (surf != NULL) {
-    SDL_Surface *s = SDL_CreateRGBSurface(0, w, h, 8, 0, 0, 0, 0);
-    if (s != NULL) {
-      SDL_SetPaletteColors(s->format->palette, surf->format->palette->colors, 0, surf->format->palette->ncolors);
-      SDL_FreeSurface(surf);
-      surf = s;
+    if (surf->w != w || surf->h != h) {
+      SDL_Surface *s = SDL_CreateRGBSurface(0, w, h, 8, 0, 0, 0, 0);
+      if (s != NULL) {
+        SDL_SetPaletteColors(s->format->palette, surf->format->palette->colors, 0, surf->format->palette->ncolors);
+        SDL_FreeSurface(surf);
+        surf = s;
+      }
     }
   }
   SDL_SetWindowSize(window, w, h);
@@ -158,6 +160,15 @@ int Y_set_videomode (int w, int h, int flags) {
   }
 }
 
+void Y_get_videomode (int *w, int *h) {
+  if (window != NULL) {
+    SDL_GetWindowSize(window, w, h);
+  } else {
+    *w = 0;
+    *h = 0;
+  }
+}
+
 int Y_videomode_setted (void) {
   return window != NULL;
 }
@@ -178,11 +189,10 @@ void Y_unset_videomode (void) {
   }
 }
 
-int Y_set_fullscreen (int yes) {
+void Y_set_fullscreen (int yes) {
   if (window != NULL) {
     SDL_SetWindowFullscreen(window, yes ? SDL_WINDOW_FULLSCREEN : 0);
   }
-  return yes;
 }
 
 int Y_get_fullscreen (void) {