From ed8b289315c8dc08a9d07381baab0f89f3de67f1 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 13 Jan 2013 14:52:19 +0900 Subject: [PATCH] Make sdl's VID_SetPalette only queue a palette change. It seems that SDL_SetColors causes a page flip, so VID_SetPalette only queue a palette change (by checking for the need to change and storing the requested palete) and VID_Update now checks for a queued palette change and updates SDL's palette if required. This fixes the flickering console in sw -sdl introduced by the cshift/centerprint change. --- libs/video/targets/vid_sdl.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/libs/video/targets/vid_sdl.c b/libs/video/targets/vid_sdl.c index 41542efe7..5ebbadfa8 100644 --- a/libs/video/targets/vid_sdl.c +++ b/libs/video/targets/vid_sdl.c @@ -84,6 +84,9 @@ static void (GLAPIENTRY *qfglFinish) (void); static int use_gl_procaddress = 0; static cvar_t *gl_driver; +static byte cached_palette[256 * 3]; +static int update_palette; + static void * QFGL_ProcAddress (const char *name, qboolean crit) { @@ -180,7 +183,7 @@ sdl_load_gl (void) } static void -VID_SetPalette (const byte *palette) +sdl_update_palette (const byte *palette) { SDL_Color colors[256]; int i; @@ -193,6 +196,15 @@ VID_SetPalette (const byte *palette) SDL_SetColors (screen, colors, 0, 256); } +static void +VID_SetPalette (const byte *palette) +{ + if (memcmp (cached_palette, palette, sizeof (cached_palette))) { + memcpy (cached_palette, palette, sizeof (cached_palette)); + update_palette = 1; + } +} + static void do_screen_buffer (void) { @@ -293,6 +305,10 @@ VID_Update (vrect_t *rects) int i, n; vrect_t *rect; + if (update_palette) { + update_palette = 0; + sdl_update_palette (cached_palette); + } // Two-pass system, since Quake doesn't do it the SDL way... // First, count the number of rectangles