shithub: choc

Download patch

ref: 97554f9a5b5fbec49b581659d6410fa878877a99
parent: 414b71b290bb833d1d3b34ab0b76127203c9417d
author: Simon Howard <[email protected]>
date: Fri Nov 28 14:50:08 EST 2014

Update video-hr code to SDL2 API.

--- a/src/i_videohr.c
+++ b/src/i_videohr.c
@@ -29,7 +29,7 @@
 #define HR_SCREENWIDTH 640
 #define HR_SCREENHEIGHT 480
 
-static SDL_Surface *hr_screen = NULL;
+static SDL_Window *hr_screen = NULL;
 static SDL_Surface *hr_surface = NULL;
 static char *window_title = "";
 
@@ -40,11 +40,12 @@
         return false;
     }
 
-    SDL_WM_SetCaption(window_title,  NULL);
-
     // Create screen surface at the native desktop pixel depth (bpp=0),
     // as we cannot trust true 8-bit to reliably work nowadays.
-    hr_screen = SDL_SetVideoMode(HR_SCREENWIDTH, HR_SCREENHEIGHT, 0, 0);
+    hr_screen = SDL_CreateWindow(window_title,
+        SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
+        HR_SCREENWIDTH, HR_SCREENHEIGHT,
+        0);
 
     if (hr_screen == NULL)
     {
@@ -145,8 +146,9 @@
     blit_rect.y = y;
     blit_rect.w = w;
     blit_rect.h = h;
-    SDL_BlitSurface(hr_surface, &blit_rect, hr_screen, &blit_rect);
-    SDL_UpdateRects(hr_screen, 1, &blit_rect);
+    SDL_BlitSurface(hr_surface, &blit_rect,
+                    SDL_GetWindowSurface(hr_screen), &blit_rect);
+    SDL_UpdateWindowSurfaceRects(hr_screen, &blit_rect, 1);
 }
 
 void I_SlamHR(const byte *buffer)
@@ -173,9 +175,10 @@
     }
 
     // After setting colors, update the screen.
-    SDL_SetColors(hr_surface, sdlpal, 0, 16);
-    SDL_BlitSurface(hr_surface, &screen_rect, hr_screen, &screen_rect);
-    SDL_UpdateRects(hr_screen, 1, &screen_rect);
+    SDL_SetPaletteColors(hr_surface->format->palette, sdlpal, 0, 16);
+    SDL_BlitSurface(hr_surface, &screen_rect,
+                    SDL_GetWindowSurface(hr_screen), &screen_rect);
+    SDL_UpdateWindowSurfaceRects(hr_screen, &screen_rect, 1);
 }
 
 void I_FadeToPaletteHR(const byte *palette)
@@ -204,7 +207,7 @@
         }
 
         I_SetPaletteHR(tmppal);
-        SDL_Flip(hr_surface);
+        SDL_UpdateWindowSurface(hr_screen);
 
         // Sleep a bit