mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-30 12:40:42 +00:00
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
This commit is contained in:
parent
5ed553f876
commit
a87c4bbd93
18 changed files with 40 additions and 35 deletions
|
@ -44,6 +44,7 @@ typedef struct vrect_s {
|
||||||
} vrect_t;
|
} vrect_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
qboolean initialized;
|
||||||
pixel_t *buffer; // invisible buffer
|
pixel_t *buffer; // invisible buffer
|
||||||
short *zbuffer;
|
short *zbuffer;
|
||||||
void *surfcache;
|
void *surfcache;
|
||||||
|
|
|
@ -99,7 +99,6 @@ void R_MarkLeaves (void);
|
||||||
|
|
||||||
extern cvar_t *scr_fov;
|
extern cvar_t *scr_fov;
|
||||||
|
|
||||||
extern byte gammatable[256];
|
|
||||||
extern qboolean lighthalf;
|
extern qboolean lighthalf;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -140,9 +140,6 @@ VID_UpdateGamma (cvar_t *vid_gamma)
|
||||||
{
|
{
|
||||||
double gamma = bound (0.1, vid_gamma->value, 9.9);
|
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
|
vid.recalc_refdef = 1; // force a surface cache flush
|
||||||
|
|
||||||
if (vid_gamma_avail && vid_system_gamma->int_val) { // Have system, use it
|
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
|
} else { // We have to hack the palette
|
||||||
Con_DPrintf ("Setting software gamma to %g\n", gamma);
|
Con_DPrintf ("Setting software gamma to %g\n", gamma);
|
||||||
VID_BuildGammaTable (gamma);
|
VID_BuildGammaTable (gamma);
|
||||||
V_UpdatePalette (); // update with the new palette
|
if (vid.initialized)
|
||||||
|
VID_SetPalette (vid_basepal); // update with the new palette
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -284,6 +284,8 @@ VID_Init (unsigned char *palette)
|
||||||
// Check for 3DFX Extensions and initialize them.
|
// Check for 3DFX Extensions and initialize them.
|
||||||
VID_Init8bitPalette ();
|
VID_Init8bitPalette ();
|
||||||
|
|
||||||
|
vid.initialzed = true;
|
||||||
|
|
||||||
Con_Printf ("Video mode %dx%d initialized.\n", scr_width, scr_height);
|
Con_Printf ("Video mode %dx%d initialized.\n", scr_width, scr_height);
|
||||||
|
|
||||||
vid.recalc_refdef = 1; // force a surface cache flush
|
vid.recalc_refdef = 1; // force a surface cache flush
|
||||||
|
|
|
@ -152,9 +152,9 @@ VID_SetPalette (unsigned char *palette)
|
||||||
pal = palette;
|
pal = palette;
|
||||||
table = d_8to24table;
|
table = d_8to24table;
|
||||||
for (i = 0; i < 255; i++) { // used to be i<256, see d_8to24table below
|
for (i = 0; i < 255; i++) { // used to be i<256, see d_8to24table below
|
||||||
r = pal[0];
|
r = gammatable[pal[0]];
|
||||||
g = pal[1];
|
g = gammatable[pal[1]];
|
||||||
b = pal[2];
|
b = gammatable[pal[2]];
|
||||||
pal += 3;
|
pal += 3;
|
||||||
|
|
||||||
#ifdef WORDS_BIGENDIAN
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
|
|
@ -148,6 +148,8 @@ VID_Init (unsigned char *palette)
|
||||||
|
|
||||||
vid_menudrawfn = VID_MenuDraw;
|
vid_menudrawfn = VID_MenuDraw;
|
||||||
vid_menukeyfn = VID_MenuKey;
|
vid_menukeyfn = VID_MenuKey;
|
||||||
|
|
||||||
|
vid.initialzed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -531,6 +531,8 @@ VID_Init (unsigned char *palette)
|
||||||
|
|
||||||
VID_InitGamma (palette);
|
VID_InitGamma (palette);
|
||||||
VID_SetPalette (palette);
|
VID_SetPalette (palette);
|
||||||
|
|
||||||
|
vid.initialzed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,8 +63,6 @@
|
||||||
#define WARP_WIDTH 320
|
#define WARP_WIDTH 320
|
||||||
#define WARP_HEIGHT 200
|
#define WARP_HEIGHT 200
|
||||||
|
|
||||||
static qboolean vid_initialized = false;
|
|
||||||
|
|
||||||
static GLXContext ctx = NULL;
|
static GLXContext ctx = NULL;
|
||||||
|
|
||||||
extern void GL_Init_Common (void);
|
extern void GL_Init_Common (void);
|
||||||
|
@ -80,7 +78,7 @@ const char *gl_extensions;
|
||||||
void
|
void
|
||||||
VID_Shutdown (void)
|
VID_Shutdown (void)
|
||||||
{
|
{
|
||||||
if (!vid_initialized)
|
if (!vid.initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Con_Printf ("VID_Shutdown\n");
|
Con_Printf ("VID_Shutdown\n");
|
||||||
|
@ -214,14 +212,14 @@ VID_Init (unsigned char *palette)
|
||||||
GL_Init ();
|
GL_Init ();
|
||||||
|
|
||||||
VID_InitGamma (palette);
|
VID_InitGamma (palette);
|
||||||
VID_SetPalette (palette);
|
|
||||||
|
|
||||||
// Check for 8-bit extension and initialize if present
|
// Check for 8-bit extension and initialize if present
|
||||||
VID_Init8bitPalette ();
|
VID_Init8bitPalette ();
|
||||||
|
VID_SetPalette (palette);
|
||||||
|
|
||||||
Con_Printf ("Video mode %dx%d initialized.\n", scr_width, scr_height);
|
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
|
vid.recalc_refdef = 1; // force a surface cache flush
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ RECT window_rect;
|
||||||
static DEVMODE gdevmode;
|
static DEVMODE gdevmode;
|
||||||
static qboolean startwindowed = 0, windowed_mode_set = 0;
|
static qboolean startwindowed = 0, windowed_mode_set = 0;
|
||||||
static int firstupdate = 1;
|
static int firstupdate = 1;
|
||||||
static qboolean vid_initialized = false, vid_palettized;
|
static qboolean vid_palettized;
|
||||||
static int lockcount;
|
static int lockcount;
|
||||||
static int vid_fulldib_on_focus_mode;
|
static int vid_fulldib_on_focus_mode;
|
||||||
static qboolean force_minimized, in_mode_set, is_mode0x13, force_mode_set;
|
static qboolean force_minimized, in_mode_set, is_mode0x13, force_mode_set;
|
||||||
|
@ -1508,7 +1508,7 @@ void
|
||||||
VID_SetDefaultMode (void)
|
VID_SetDefaultMode (void)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (vid_initialized)
|
if (vid.initialized)
|
||||||
VID_SetMode (0, vid_curpal);
|
VID_SetMode (0, vid_curpal);
|
||||||
|
|
||||||
IN_DeactivateMouse ();
|
IN_DeactivateMouse ();
|
||||||
|
@ -2047,7 +2047,7 @@ VID_Init (unsigned char *palette)
|
||||||
hide_window = false;
|
hide_window = false;
|
||||||
// S_Init ();
|
// S_Init ();
|
||||||
|
|
||||||
vid_initialized = true;
|
vid.initialized = true;
|
||||||
|
|
||||||
force_mode_set = true;
|
force_mode_set = true;
|
||||||
VID_SetMode (vid_default, palette);
|
VID_SetMode (vid_default, palette);
|
||||||
|
@ -2093,7 +2093,7 @@ VID_Shutdown (void)
|
||||||
DestroyWindow (hwnd_dialog);
|
DestroyWindow (hwnd_dialog);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (vid_initialized) {
|
if (vid.initialized) {
|
||||||
if (modestate == MS_FULLDIB)
|
if (modestate == MS_FULLDIB)
|
||||||
ChangeDisplaySettings (NULL, CDS_FULLSCREEN);
|
ChangeDisplaySettings (NULL, CDS_FULLSCREEN);
|
||||||
|
|
||||||
|
@ -2112,7 +2112,7 @@ VID_Shutdown (void)
|
||||||
MGL_exit ();
|
MGL_exit ();
|
||||||
|
|
||||||
vid_testingmode = 0;
|
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;
|
int i, j, reps, repshift;
|
||||||
vrect_t rect;
|
vrect_t rect;
|
||||||
|
|
||||||
if (!vid_initialized)
|
if (!vid.initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (vid.aspect > 1.5) {
|
if (vid.aspect > 1.5) {
|
||||||
|
@ -2377,7 +2377,7 @@ D_EndDirectRect (int x, int y, int width, int height)
|
||||||
int i, j, reps, repshift;
|
int i, j, reps, repshift;
|
||||||
vrect_t rect;
|
vrect_t rect;
|
||||||
|
|
||||||
if (!vid_initialized)
|
if (!vid.initialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (vid.aspect > 1.5) {
|
if (vid.aspect > 1.5) {
|
||||||
|
@ -2542,7 +2542,7 @@ AppActivate (BOOL fActive, BOOL minimize)
|
||||||
|
|
||||||
MGL_appActivate (windc, ActiveApp);
|
MGL_appActivate (windc, ActiveApp);
|
||||||
|
|
||||||
if (vid_initialized) {
|
if (vid.initialized) {
|
||||||
// yield the palette if we're losing the focus
|
// yield the palette if we're losing the focus
|
||||||
hdc = GetDC (NULL);
|
hdc = GetDC (NULL);
|
||||||
|
|
||||||
|
@ -2588,7 +2588,7 @@ AppActivate (BOOL fActive, BOOL minimize)
|
||||||
if (!in_mode_set) {
|
if (!in_mode_set) {
|
||||||
if (ActiveApp) {
|
if (ActiveApp) {
|
||||||
if (vid_fulldib_on_focus_mode) {
|
if (vid_fulldib_on_focus_mode) {
|
||||||
if (vid_initialized) {
|
if (vid.initialized) {
|
||||||
msg_suppress_1 = true; // don't want to see normal mode
|
msg_suppress_1 = true; // don't want to see normal mode
|
||||||
// set message
|
// set message
|
||||||
VID_SetMode (vid_fulldib_on_focus_mode, vid_curpal);
|
VID_SetMode (vid_fulldib_on_focus_mode, vid_curpal);
|
||||||
|
@ -2612,7 +2612,7 @@ AppActivate (BOOL fActive, BOOL minimize)
|
||||||
|
|
||||||
if (!ActiveApp) {
|
if (!ActiveApp) {
|
||||||
if (modestate == MS_FULLDIB) {
|
if (modestate == MS_FULLDIB) {
|
||||||
if (vid_initialized) {
|
if (vid.initialized) {
|
||||||
force_minimized = true;
|
force_minimized = true;
|
||||||
i = vid_fulldib_on_focus_mode;
|
i = vid_fulldib_on_focus_mode;
|
||||||
msg_suppress_1 = true; // don't want to see normal 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;
|
scr_fullupdate = 0;
|
||||||
|
|
||||||
if (vid_initialized && !in_mode_set && windc
|
if (vid.initialized && !in_mode_set && windc
|
||||||
&& MGL_activatePalette (windc, false) && !Minimized) {
|
&& MGL_activatePalette (windc, false) && !Minimized) {
|
||||||
VID_SetPalette (vid_curpal);
|
VID_SetPalette (vid_curpal);
|
||||||
InvalidateRect (mainwindow, NULL, false);
|
InvalidateRect (mainwindow, NULL, false);
|
||||||
|
|
|
@ -147,6 +147,8 @@ VID_Init (unsigned char *palette)
|
||||||
mainwindow=GetActiveWindow();
|
mainwindow=GetActiveWindow();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
vid.initialzed = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -71,8 +71,6 @@ HWND mainwindow;
|
||||||
#define WARP_WIDTH 320
|
#define WARP_WIDTH 320
|
||||||
#define WARP_HEIGHT 200
|
#define WARP_HEIGHT 200
|
||||||
|
|
||||||
static qboolean vid_initialized = false;
|
|
||||||
|
|
||||||
cvar_t *vid_fullscreen;
|
cvar_t *vid_fullscreen;
|
||||||
cvar_t *vid_system_gamma;
|
cvar_t *vid_system_gamma;
|
||||||
|
|
||||||
|
@ -102,7 +100,7 @@ VID_SDL_GammaCheck (void)
|
||||||
void
|
void
|
||||||
VID_Shutdown (void)
|
VID_Shutdown (void)
|
||||||
{
|
{
|
||||||
// if (!vid_initialized)
|
// if (!vid.initialized)
|
||||||
// return;
|
// return;
|
||||||
// Con_Printf ("VID_Shutdown\n");
|
// Con_Printf ("VID_Shutdown\n");
|
||||||
SDL_Quit ();
|
SDL_Quit ();
|
||||||
|
@ -237,7 +235,7 @@ VID_Init (unsigned char *palette)
|
||||||
|
|
||||||
Con_Printf ("Video mode %dx%d initialized.\n", scr_width, scr_height);
|
Con_Printf ("Video mode %dx%d initialized.\n", scr_width, scr_height);
|
||||||
|
|
||||||
vid_initialized = true;
|
vid.initialized = true;
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
// FIXME: EVIL thing - but needed for win32 until
|
// FIXME: EVIL thing - but needed for win32 until
|
||||||
|
|
|
@ -812,6 +812,8 @@ VID_Init (unsigned char *palette)
|
||||||
vid_menudrawfn = VID_MenuDraw;
|
vid_menudrawfn = VID_MenuDraw;
|
||||||
vid_menukeyfn = VID_MenuKey;
|
vid_menukeyfn = VID_MenuKey;
|
||||||
|
|
||||||
|
|
||||||
|
vid.initialzed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -615,6 +615,8 @@ VID_Init (unsigned char *palette)
|
||||||
|
|
||||||
vid_menudrawfn = VID_MenuDraw;
|
vid_menudrawfn = VID_MenuDraw;
|
||||||
vid_menukeyfn = VID_MenuKey;
|
vid_menukeyfn = VID_MenuKey;
|
||||||
|
|
||||||
|
vid.initialzed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
VID_ResetFramebuffer ()
|
VID_ResetFramebuffer ()
|
||||||
|
|
|
@ -511,6 +511,8 @@ VID_Init (unsigned char *palette)
|
||||||
|
|
||||||
VID_InitGamma (palette);
|
VID_InitGamma (palette);
|
||||||
VID_SetPalette (palette);
|
VID_SetPalette (palette);
|
||||||
|
|
||||||
|
vid.initialzed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,6 @@ static int nummodes;
|
||||||
static vmode_t badmode;
|
static vmode_t badmode;
|
||||||
|
|
||||||
static DEVMODE gdevmode;
|
static DEVMODE gdevmode;
|
||||||
static qboolean vid_initialized = false;
|
|
||||||
static qboolean windowed, leavecurrentmode;
|
static qboolean windowed, leavecurrentmode;
|
||||||
static qboolean vid_canalttab = false;
|
static qboolean vid_canalttab = false;
|
||||||
static qboolean vid_wassuspended = false;
|
static qboolean vid_wassuspended = false;
|
||||||
|
@ -522,7 +521,7 @@ VID_Shutdown (void)
|
||||||
DestroyWindow (hwnd_dialog);
|
DestroyWindow (hwnd_dialog);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (vid_initialized) {
|
if (vid.initialized) {
|
||||||
vid_canalttab = false;
|
vid_canalttab = false;
|
||||||
hRC = wglGetCurrentContext ();
|
hRC = wglGetCurrentContext ();
|
||||||
hDC = wglGetCurrentDC ();
|
hDC = wglGetCurrentDC ();
|
||||||
|
@ -1353,7 +1352,7 @@ VID_Init (unsigned char *palette)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vid_initialized = true;
|
vid.initialized = true;
|
||||||
|
|
||||||
if ((i = COM_CheckParm ("-conwidth")) != 0)
|
if ((i = COM_CheckParm ("-conwidth")) != 0)
|
||||||
vid.conwidth = atoi (com_argv[i + 1]);
|
vid.conwidth = atoi (com_argv[i + 1]);
|
||||||
|
|
|
@ -550,6 +550,8 @@ VID_Init (unsigned char *palette)
|
||||||
|
|
||||||
// XSynchronize (x_disp, False);
|
// XSynchronize (x_disp, False);
|
||||||
X11_AddEvent (x_shmeventtype, event_shm);
|
X11_AddEvent (x_shmeventtype, event_shm);
|
||||||
|
|
||||||
|
vid.initialzed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -47,8 +47,6 @@
|
||||||
|
|
||||||
extern double host_frametime;
|
extern double host_frametime;
|
||||||
|
|
||||||
extern byte gammatable[256];
|
|
||||||
|
|
||||||
extern cvar_t *cl_cshift_powerup;
|
extern cvar_t *cl_cshift_powerup;
|
||||||
|
|
||||||
byte ramps[3][256];
|
byte ramps[3][256];
|
||||||
|
|
|
@ -48,8 +48,6 @@
|
||||||
|
|
||||||
extern double host_frametime;
|
extern double host_frametime;
|
||||||
|
|
||||||
extern byte gammatable[256];
|
|
||||||
|
|
||||||
extern cvar_t *cl_cshift_powerup;
|
extern cvar_t *cl_cshift_powerup;
|
||||||
|
|
||||||
byte ramps[3][256];
|
byte ramps[3][256];
|
||||||
|
|
Loading…
Reference in a new issue