From a87c4bbd9327b7f9aa078d293f2d33964f5958f9 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 25 May 2001 04:03:47 +0000 Subject: [PATCH] vid.c: Don't bother checking vid_gamma for CVAR_ROM becuase it is impossible to get to VID_UpdateGamma when it is set except for when the cvar is initially created, and we /want/ the code to execute in that case. vid.h: add initialized to viddef_t vid_common_gl.c: actually /use/ gammatable (it tends to help) vid_*.c: clean up rendundant decls of gammatable, vid_initialized (now vid.initialized) and make sure vid.initialized gets set. gl_view.c: remove gammatable decls --- include/QF/vid.h | 1 + libs/video/renderer/gl/gl_rmain.c | 1 - libs/video/targets/vid.c | 6 ++---- libs/video/targets/vid_3dfxsvga.c | 2 ++ libs/video/targets/vid_common_gl.c | 6 +++--- libs/video/targets/vid_dos.c | 2 ++ libs/video/targets/vid_fbdev.c | 2 ++ libs/video/targets/vid_glx.c | 8 +++----- libs/video/targets/vid_mgl.c | 22 +++++++++++----------- libs/video/targets/vid_sdl.c | 2 ++ libs/video/targets/vid_sgl.c | 6 ++---- libs/video/targets/vid_sunx.c | 2 ++ libs/video/targets/vid_sunxil.c | 2 ++ libs/video/targets/vid_svgalib.c | 2 ++ libs/video/targets/vid_wgl.c | 5 ++--- libs/video/targets/vid_x11.c | 2 ++ nq/source/gl_view.c | 2 -- qw/source/gl_view.c | 2 -- 18 files changed, 40 insertions(+), 35 deletions(-) diff --git a/include/QF/vid.h b/include/QF/vid.h index 716529416..b1ec78bda 100644 --- a/include/QF/vid.h +++ b/include/QF/vid.h @@ -44,6 +44,7 @@ typedef struct vrect_s { } vrect_t; typedef struct { + qboolean initialized; pixel_t *buffer; // invisible buffer short *zbuffer; void *surfcache; diff --git a/libs/video/renderer/gl/gl_rmain.c b/libs/video/renderer/gl/gl_rmain.c index f2923c8d5..d80c8e69e 100644 --- a/libs/video/renderer/gl/gl_rmain.c +++ b/libs/video/renderer/gl/gl_rmain.c @@ -99,7 +99,6 @@ void R_MarkLeaves (void); extern cvar_t *scr_fov; -extern byte gammatable[256]; extern qboolean lighthalf; diff --git a/libs/video/targets/vid.c b/libs/video/targets/vid.c index 252186def..f9922812e 100644 --- a/libs/video/targets/vid.c +++ b/libs/video/targets/vid.c @@ -140,9 +140,6 @@ VID_UpdateGamma (cvar_t *vid_gamma) { double gamma = bound (0.1, vid_gamma->value, 9.9); - if (vid_gamma->flags & CVAR_ROM) // System gamma unavailable - return; - vid.recalc_refdef = 1; // force a surface cache flush if (vid_gamma_avail && vid_system_gamma->int_val) { // Have system, use it @@ -152,7 +149,8 @@ VID_UpdateGamma (cvar_t *vid_gamma) } else { // We have to hack the palette Con_DPrintf ("Setting software gamma to %g\n", gamma); VID_BuildGammaTable (gamma); - V_UpdatePalette (); // update with the new palette + if (vid.initialized) + VID_SetPalette (vid_basepal); // update with the new palette } } diff --git a/libs/video/targets/vid_3dfxsvga.c b/libs/video/targets/vid_3dfxsvga.c index 5d445c30b..0db783e7e 100644 --- a/libs/video/targets/vid_3dfxsvga.c +++ b/libs/video/targets/vid_3dfxsvga.c @@ -284,6 +284,8 @@ VID_Init (unsigned char *palette) // Check for 3DFX Extensions and initialize them. VID_Init8bitPalette (); + vid.initialzed = true; + Con_Printf ("Video mode %dx%d initialized.\n", scr_width, scr_height); vid.recalc_refdef = 1; // force a surface cache flush diff --git a/libs/video/targets/vid_common_gl.c b/libs/video/targets/vid_common_gl.c index 23ace557e..7a8d7c7f7 100644 --- a/libs/video/targets/vid_common_gl.c +++ b/libs/video/targets/vid_common_gl.c @@ -152,9 +152,9 @@ VID_SetPalette (unsigned char *palette) pal = palette; table = d_8to24table; for (i = 0; i < 255; i++) { // used to be i<256, see d_8to24table below - r = pal[0]; - g = pal[1]; - b = pal[2]; + r = gammatable[pal[0]]; + g = gammatable[pal[1]]; + b = gammatable[pal[2]]; pal += 3; #ifdef WORDS_BIGENDIAN diff --git a/libs/video/targets/vid_dos.c b/libs/video/targets/vid_dos.c index 5711b0049..778664727 100644 --- a/libs/video/targets/vid_dos.c +++ b/libs/video/targets/vid_dos.c @@ -148,6 +148,8 @@ VID_Init (unsigned char *palette) vid_menudrawfn = VID_MenuDraw; vid_menukeyfn = VID_MenuKey; + + vid.initialzed = true; } diff --git a/libs/video/targets/vid_fbdev.c b/libs/video/targets/vid_fbdev.c index 6f209df3d..730941167 100644 --- a/libs/video/targets/vid_fbdev.c +++ b/libs/video/targets/vid_fbdev.c @@ -531,6 +531,8 @@ VID_Init (unsigned char *palette) VID_InitGamma (palette); VID_SetPalette (palette); + + vid.initialzed = true; } } diff --git a/libs/video/targets/vid_glx.c b/libs/video/targets/vid_glx.c index eef2c4d87..0ac9fa8b7 100644 --- a/libs/video/targets/vid_glx.c +++ b/libs/video/targets/vid_glx.c @@ -63,8 +63,6 @@ #define WARP_WIDTH 320 #define WARP_HEIGHT 200 -static qboolean vid_initialized = false; - static GLXContext ctx = NULL; extern void GL_Init_Common (void); @@ -80,7 +78,7 @@ const char *gl_extensions; void VID_Shutdown (void) { - if (!vid_initialized) + if (!vid.initialized) return; Con_Printf ("VID_Shutdown\n"); @@ -214,14 +212,14 @@ VID_Init (unsigned char *palette) GL_Init (); VID_InitGamma (palette); - VID_SetPalette (palette); // Check for 8-bit extension and initialize if present VID_Init8bitPalette (); + VID_SetPalette (palette); Con_Printf ("Video mode %dx%d initialized.\n", scr_width, scr_height); - vid_initialized = true; + vid.initialized = true; vid.recalc_refdef = 1; // force a surface cache flush } diff --git a/libs/video/targets/vid_mgl.c b/libs/video/targets/vid_mgl.c index 69cec62b8..1159ea2f6 100644 --- a/libs/video/targets/vid_mgl.c +++ b/libs/video/targets/vid_mgl.c @@ -82,7 +82,7 @@ RECT window_rect; static DEVMODE gdevmode; static qboolean startwindowed = 0, windowed_mode_set = 0; static int firstupdate = 1; -static qboolean vid_initialized = false, vid_palettized; +static qboolean vid_palettized; static int lockcount; static int vid_fulldib_on_focus_mode; static qboolean force_minimized, in_mode_set, is_mode0x13, force_mode_set; @@ -1508,7 +1508,7 @@ void VID_SetDefaultMode (void) { - if (vid_initialized) + if (vid.initialized) VID_SetMode (0, vid_curpal); IN_DeactivateMouse (); @@ -2047,7 +2047,7 @@ VID_Init (unsigned char *palette) hide_window = false; // S_Init (); - vid_initialized = true; + vid.initialized = true; force_mode_set = true; VID_SetMode (vid_default, palette); @@ -2093,7 +2093,7 @@ VID_Shutdown (void) DestroyWindow (hwnd_dialog); #endif - if (vid_initialized) { + if (vid.initialized) { if (modestate == MS_FULLDIB) ChangeDisplaySettings (NULL, CDS_FULLSCREEN); @@ -2112,7 +2112,7 @@ VID_Shutdown (void) MGL_exit (); vid_testingmode = 0; - vid_initialized = 0; + vid.initialized = 0; } } @@ -2294,7 +2294,7 @@ D_BeginDirectRect (int x, int y, byte * pbitmap, int width, int height) int i, j, reps, repshift; vrect_t rect; - if (!vid_initialized) + if (!vid.initialized) return; if (vid.aspect > 1.5) { @@ -2377,7 +2377,7 @@ D_EndDirectRect (int x, int y, int width, int height) int i, j, reps, repshift; vrect_t rect; - if (!vid_initialized) + if (!vid.initialized) return; if (vid.aspect > 1.5) { @@ -2542,7 +2542,7 @@ AppActivate (BOOL fActive, BOOL minimize) MGL_appActivate (windc, ActiveApp); - if (vid_initialized) { + if (vid.initialized) { // yield the palette if we're losing the focus hdc = GetDC (NULL); @@ -2588,7 +2588,7 @@ AppActivate (BOOL fActive, BOOL minimize) if (!in_mode_set) { if (ActiveApp) { if (vid_fulldib_on_focus_mode) { - if (vid_initialized) { + if (vid.initialized) { msg_suppress_1 = true; // don't want to see normal mode // set message VID_SetMode (vid_fulldib_on_focus_mode, vid_curpal); @@ -2612,7 +2612,7 @@ AppActivate (BOOL fActive, BOOL minimize) if (!ActiveApp) { if (modestate == MS_FULLDIB) { - if (vid_initialized) { + if (vid.initialized) { force_minimized = true; i = vid_fulldib_on_focus_mode; msg_suppress_1 = true; // don't want to see normal mode @@ -2852,7 +2852,7 @@ MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) scr_fullupdate = 0; - if (vid_initialized && !in_mode_set && windc + if (vid.initialized && !in_mode_set && windc && MGL_activatePalette (windc, false) && !Minimized) { VID_SetPalette (vid_curpal); InvalidateRect (mainwindow, NULL, false); diff --git a/libs/video/targets/vid_sdl.c b/libs/video/targets/vid_sdl.c index 508ea310b..5adae9312 100644 --- a/libs/video/targets/vid_sdl.c +++ b/libs/video/targets/vid_sdl.c @@ -147,6 +147,8 @@ VID_Init (unsigned char *palette) mainwindow=GetActiveWindow(); #endif + vid.initialzed = true; + } void diff --git a/libs/video/targets/vid_sgl.c b/libs/video/targets/vid_sgl.c index 4f976ed01..c257defdf 100644 --- a/libs/video/targets/vid_sgl.c +++ b/libs/video/targets/vid_sgl.c @@ -71,8 +71,6 @@ HWND mainwindow; #define WARP_WIDTH 320 #define WARP_HEIGHT 200 -static qboolean vid_initialized = false; - cvar_t *vid_fullscreen; cvar_t *vid_system_gamma; @@ -102,7 +100,7 @@ VID_SDL_GammaCheck (void) void VID_Shutdown (void) { -// if (!vid_initialized) +// if (!vid.initialized) // return; // Con_Printf ("VID_Shutdown\n"); SDL_Quit (); @@ -237,7 +235,7 @@ VID_Init (unsigned char *palette) Con_Printf ("Video mode %dx%d initialized.\n", scr_width, scr_height); - vid_initialized = true; + vid.initialized = true; #ifdef WIN32 // FIXME: EVIL thing - but needed for win32 until diff --git a/libs/video/targets/vid_sunx.c b/libs/video/targets/vid_sunx.c index 7202fa257..38b589022 100644 --- a/libs/video/targets/vid_sunx.c +++ b/libs/video/targets/vid_sunx.c @@ -812,6 +812,8 @@ VID_Init (unsigned char *palette) vid_menudrawfn = VID_MenuDraw; vid_menukeyfn = VID_MenuKey; + + vid.initialzed = true; } void diff --git a/libs/video/targets/vid_sunxil.c b/libs/video/targets/vid_sunxil.c index 66d70f990..bf3a9c2ea 100644 --- a/libs/video/targets/vid_sunxil.c +++ b/libs/video/targets/vid_sunxil.c @@ -615,6 +615,8 @@ VID_Init (unsigned char *palette) vid_menudrawfn = VID_MenuDraw; vid_menukeyfn = VID_MenuKey; + + vid.initialzed = true; } VID_ResetFramebuffer () diff --git a/libs/video/targets/vid_svgalib.c b/libs/video/targets/vid_svgalib.c index 58dd97d5d..6ba3597cb 100644 --- a/libs/video/targets/vid_svgalib.c +++ b/libs/video/targets/vid_svgalib.c @@ -511,6 +511,8 @@ VID_Init (unsigned char *palette) VID_InitGamma (palette); VID_SetPalette (palette); + + vid.initialzed = true; } } diff --git a/libs/video/targets/vid_wgl.c b/libs/video/targets/vid_wgl.c index 9b4f85b60..b7e538702 100644 --- a/libs/video/targets/vid_wgl.c +++ b/libs/video/targets/vid_wgl.c @@ -114,7 +114,6 @@ static int nummodes; static vmode_t badmode; static DEVMODE gdevmode; -static qboolean vid_initialized = false; static qboolean windowed, leavecurrentmode; static qboolean vid_canalttab = false; static qboolean vid_wassuspended = false; @@ -522,7 +521,7 @@ VID_Shutdown (void) DestroyWindow (hwnd_dialog); #endif - if (vid_initialized) { + if (vid.initialized) { vid_canalttab = false; hRC = wglGetCurrentContext (); hDC = wglGetCurrentDC (); @@ -1353,7 +1352,7 @@ VID_Init (unsigned char *palette) } } - vid_initialized = true; + vid.initialized = true; if ((i = COM_CheckParm ("-conwidth")) != 0) vid.conwidth = atoi (com_argv[i + 1]); diff --git a/libs/video/targets/vid_x11.c b/libs/video/targets/vid_x11.c index 8949c0aee..23f409671 100644 --- a/libs/video/targets/vid_x11.c +++ b/libs/video/targets/vid_x11.c @@ -550,6 +550,8 @@ VID_Init (unsigned char *palette) // XSynchronize (x_disp, False); X11_AddEvent (x_shmeventtype, event_shm); + + vid.initialzed = true; } void diff --git a/nq/source/gl_view.c b/nq/source/gl_view.c index e5d95bdbc..fbaf15c81 100644 --- a/nq/source/gl_view.c +++ b/nq/source/gl_view.c @@ -47,8 +47,6 @@ extern double host_frametime; -extern byte gammatable[256]; - extern cvar_t *cl_cshift_powerup; byte ramps[3][256]; diff --git a/qw/source/gl_view.c b/qw/source/gl_view.c index f52723a7e..d0dd2cb29 100644 --- a/qw/source/gl_view.c +++ b/qw/source/gl_view.c @@ -48,8 +48,6 @@ extern double host_frametime; -extern byte gammatable[256]; - extern cvar_t *cl_cshift_powerup; byte ramps[3][256];