foxygit / doom Log in
commit 97554f9a5b5fbec49b581659d6410fa878877a99
Author:     Simon Howard <fraggle@soulsphere.org>
AuthorDate: Fri Nov 28 19:50:08 2014 -0500
Commit:     Simon Howard <fraggle@soulsphere.org>
CommitDate: Fri Nov 28 19:50:08 2014 -0500

    Update video-hr code to SDL2 API.
---
 src/i_videohr.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/i_videohr.c b/src/i_videohr.c
index ec8dbb97..86d25710 100644
--- 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 @@ boolean I_SetVideoModeHR(void)
         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 @@ void I_SlamBlockHR(int x, int y, int w, int h, const byte *src)
     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 @@ void I_SetPaletteHR(const byte *palette)
     }

     // 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 @@ void I_FadeToPaletteHR(const byte *palette)
         }

         I_SetPaletteHR(tmppal);
-        SDL_Flip(hr_surface);
+        SDL_UpdateWindowSurface(hr_screen);

         // Sleep a bit