diff --git a/engine/client/render.h b/engine/client/render.h index 54e978b2d..179b0760c 100644 --- a/engine/client/render.h +++ b/engine/client/render.h @@ -287,7 +287,7 @@ struct mleaf_s *GLMod_PointInLeaf (struct model_s *model, float *p); void GLMod_Think (void); void GLMod_NowLoadExternal(void); void GLR_WipeStains(void); -void R_LoadSkys (void); +void GLR_LoadSkys (void); #endif #if defined(SWQUAKE) diff --git a/engine/client/renderer.c b/engine/client/renderer.c index 065a14591..72b04efd3 100644 --- a/engine/client/renderer.c +++ b/engine/client/renderer.c @@ -245,11 +245,11 @@ void R_BulletenForce_f (void); rendererstate_t currentrendererstate; -cvar_t gl_skyboxname = SCVAR("r_skybox", ""); +cvar_t r_skyboxname = SCVARF("r_skybox", "", CVAR_RENDERERCALLBACK); cvar_t r_fastsky = SCVAR("r_fastsky", "0"); cvar_t r_fastskycolour = SCVAR("r_fastskycolour", "0"); -cvar_t r_menutint = SCVAR("r_menutint", "0.68 0.4 0.13"); +cvar_t r_menutint = SCVARF("r_menutint", "0.68 0.4 0.13", CVAR_RENDERERCALLBACK); #if defined(RGLQUAKE) cvar_t gl_schematics = SCVAR("gl_schematics","0"); @@ -496,7 +496,7 @@ void Renderer_Init(void) Cvar_Register (&vid_desktopsettings, VIDCOMMANDGROUP); - Cvar_Register (&gl_skyboxname, GRAPHICALNICETIES); + Cvar_Register (&r_skyboxname, GRAPHICALNICETIES); Cvar_Register(&r_dodgytgafiles, "Bug fixes"); Cvar_Register(&r_dodgypcxfiles, "Bug fixes"); @@ -1513,8 +1513,6 @@ qboolean R_ApplyRenderer (rendererstate_t *newr) TRACE(("dbg: R_ApplyRenderer: old renderer closed\n")); - gl_skyboxname.modified = true; - pmove.numphysent = 0; if (qrenderer) //graphics stuff only when not dedicated diff --git a/engine/gl/gl_draw.c b/engine/gl/gl_draw.c index 0e97a63fb..c336c8b75 100644 --- a/engine/gl/gl_draw.c +++ b/engine/gl/gl_draw.c @@ -2008,48 +2008,44 @@ Draw_FadeScreen ================ */ vec3_t fadecolor; -vec3_t fadecolorreal; int faderender; -int fademodified; + +void GLR_Menutint_Callback (struct cvar_s *var, char *oldvalue) +{ + // parse r_menutint and clear defaults + faderender = GL_DST_COLOR; + + if (var->string[0]) + SCR_StringToRGB(var->string, fadecolor, 1); + else + faderender = 0; + + // bounds check and inverse check + if (faderender) + { + if (fadecolor[0] < 0) + { + faderender = GL_ONE_MINUS_DST_COLOR; + fadecolor[0] = -(fadecolor[0]); + } + if (fadecolor[1] < 0) + { + faderender = GL_ONE_MINUS_DST_COLOR; + fadecolor[1] = -(fadecolor[1]); + } + if (fadecolor[2] < 0) + { + faderender = GL_ONE_MINUS_DST_COLOR; + fadecolor[2] = -(fadecolor[2]); + } + } +} void GLDraw_FadeScreen (void) { - extern cvar_t r_menutint, gl_menutint_shader; + extern cvar_t gl_menutint_shader; extern int scenepp_texture, scenepp_mt_program, scenepp_mt_parm_colorf, scenepp_mt_parm_inverti; - if (fademodified != r_menutint.modified) - { - // parse r_menutint and clear defaults - faderender = GL_DST_COLOR; - - if (r_menutint.string[0]) - SCR_StringToRGB(r_menutint.string, fadecolor, 1); - else - faderender = 0; - - // bounds check and inverse check - if (faderender) - { - if (fadecolor[0] < 0) - { - faderender = GL_ONE_MINUS_DST_COLOR; - fadecolor[0] = -(fadecolor[0]); - } - if (fadecolor[1] < 0) - { - faderender = GL_ONE_MINUS_DST_COLOR; - fadecolor[1] = -(fadecolor[1]); - } - if (fadecolor[2] < 0) - { - faderender = GL_ONE_MINUS_DST_COLOR; - fadecolor[2] = -(fadecolor[2]); - } - } - - fademodified = r_menutint.modified; - } - if (!faderender) return; diff --git a/engine/gl/gl_rmisc.c b/engine/gl/gl_rmisc.c index 883548b40..a918549a5 100644 --- a/engine/gl/gl_rmisc.c +++ b/engine/gl/gl_rmisc.c @@ -655,13 +655,15 @@ if (!data) void GLR_TimeRefresh_f (void); extern cvar_t gl_bump; -extern cvar_t r_stains, r_stainfadetime, r_stainfadeammount; +extern cvar_t r_stains, r_stainfadetime, r_stainfadeammount, r_menutint; // callback defines -extern cvar_t crosshair, crosshairimage, crosshaircolor; +extern cvar_t crosshair, crosshairimage, crosshaircolor, r_skyboxname; void GLCrosshairimage_Callback(struct cvar_s *var, char *oldvalue); void GLCrosshair_Callback(struct cvar_s *var, char *oldvalue); void GLCrosshaircolor_Callback(struct cvar_s *var, char *oldvalue); +void GLR_Skyboxname_Callback(struct cvar_s *var, char *oldvalue); +void GLR_Menutint_Callback (struct cvar_s *var, char *oldvalue); void GLR_DeInit (void) { @@ -674,6 +676,8 @@ void GLR_DeInit (void) Cvar_Unhook(&crosshair); Cvar_Unhook(&crosshairimage); Cvar_Unhook(&crosshaircolor); + Cvar_Unhook(&r_skyboxname); + Cvar_Unhook(&r_menutint); GLDraw_DeInit(); @@ -690,6 +694,8 @@ void GLR_Init (void) Cvar_Hook(&crosshair, GLCrosshair_Callback); Cvar_Hook(&crosshairimage, GLCrosshairimage_Callback); Cvar_Hook(&crosshaircolor, GLCrosshaircolor_Callback); + Cvar_Hook(&r_skyboxname, GLR_Skyboxname_Callback); + Cvar_Hook(&r_menutint, GLR_Menutint_Callback); R_InitBubble(); @@ -1043,7 +1049,7 @@ TRACE(("dbg: GLR_NewMap: figuring out skys and mirrors\n")); } TRACE(("dbg: GLR_NewMap: that skybox thang\n")); //#ifdef QUAKE2 - R_LoadSkys (); + GLR_LoadSkys (); //#endif TRACE(("dbg: GLR_NewMap: ui\n")); #ifdef VM_UI diff --git a/engine/gl/gl_warp.c b/engine/gl/gl_warp.c index dfe90c3aa..d19aa78a5 100644 --- a/engine/gl/gl_warp.c +++ b/engine/gl/gl_warp.c @@ -47,12 +47,11 @@ qboolean usingskybox; msurface_t *warpface; -extern cvar_t gl_skyboxname; +extern cvar_t r_skyboxname; extern cvar_t gl_skyboxdist; extern cvar_t r_fastsky; extern cvar_t r_fastskycolour; char defaultskybox[MAX_QPATH]; -qboolean reloadskybox; int skyboxtex[6]; @@ -301,15 +300,15 @@ static char *skyname_pattern[] = { "gfx/env/%s%s" }; -void R_LoadSkys (void) +void GLR_LoadSkys (void) { int i; char name[MAX_QPATH]; char *boxname; int p, s; - if (*gl_skyboxname.string) - boxname = gl_skyboxname.string; //user forced + if (*r_skyboxname.string) + boxname = r_skyboxname.string; //user forced else boxname = defaultskybox; @@ -350,7 +349,6 @@ void R_LoadSkys (void) break; } } - reloadskybox = false; } @@ -358,13 +356,17 @@ qboolean GLR_CheckSky() { return true; } + +void GLR_Skyboxname_Callback(struct cvar_s *var, char *oldvalue) +{ + GLR_LoadSkys(); +} + void GLR_SetSky(char *name, float rotate, vec3_t axis) //called from the client code, once per level { Q_strncpyz(defaultskybox, name, sizeof(defaultskybox)); - if (!*gl_skyboxname.string) //don't override a user's settings - { - reloadskybox = true; - } + if (!*r_skyboxname.string) //don't override a user's settings + GLR_Skyboxname_Callback(&r_skyboxname, ""); skyrotate = rotate; VectorCopy(axis, skyaxis); @@ -772,14 +774,6 @@ void R_ClearSkyBox (void) usingskybox = false; return; } - if (gl_skyboxname.modified) - { - gl_skyboxname.modified = false; - reloadskybox = true; - } - - if (reloadskybox) - R_LoadSkys(); if (!skyboxtex[0] || !skyboxtex[1] || !skyboxtex[2] || !skyboxtex[3] || !skyboxtex[4] || !skyboxtex[5]) { diff --git a/engine/sw/d_trans.c b/engine/sw/d_trans.c index 21884bfcd..fc6929a52 100644 --- a/engine/sw/d_trans.c +++ b/engine/sw/d_trans.c @@ -16,15 +16,11 @@ qbyte *pal555to8; int swzpal[TRANS_LEVELS][256]; // menutint -palremap_t *RebuildMenuTint(void); palremap_t *mtpalremap; // IB remap palremap_t *ib_remap; -extern cvar_t r_menutint; -int mtmodified; - #define palette host_basepal #define _abs(x) ((x)*(x)) @@ -44,7 +40,6 @@ void D_ShutdownTrans(void) } mtpalremap = NULL; - mtmodified = 0; ib_remap = NULL; } @@ -57,7 +52,6 @@ void D_InitTrans(void) srctable = swzpal[0]; dsttable = swzpal[TRANS_MAX]; - mtpalremap = RebuildMenuTint(); ib_remap = D_IdentityRemap(); } @@ -413,12 +407,12 @@ palremap_t *D_GetPaletteRemap(int red, int green, int blue, qboolean desaturate, return palremaps + deref; } -palremap_t *RebuildMenuTint(void) +palremap_t *RebuildMenuTint(struct cvar_s *var) { vec3_t rgb; - if (r_menutint.string[0]) - SCR_StringToRGB(r_menutint.string, rgb, 1); + if (var->string[0]) + SCR_StringToRGB(var->string, rgb, 1); else return NULL; @@ -443,17 +437,16 @@ void D_DereferenceRemap(palremap_t *palremap) } } +void SWR_Menutint_Callback(struct cvar_s *var, char *oldvalue) +{ + if (mtpalremap) + D_DereferenceRemap(mtpalremap); + + mtpalremap = RebuildMenuTint(var); +} + qbyte *D_GetMenuTintPal(void) { - if (mtmodified != r_menutint.modified) - { - if (mtpalremap) - D_DereferenceRemap(mtpalremap); - - mtpalremap = RebuildMenuTint(); - mtmodified = r_menutint.modified; - } - if (mtpalremap && mtpalremap != palremaps) return mtpalremap->pal; else diff --git a/engine/sw/r_draw.c b/engine/sw/r_draw.c index 8eea4a4d4..faae1b929 100644 --- a/engine/sw/r_draw.c +++ b/engine/sw/r_draw.c @@ -120,8 +120,6 @@ static char *suf[6] = {"rt", "bk", "lf", "ft", "up", "dn"}; int r_skysideimage[6] = {5, 2, 4, 1, 0, 3}; extern mtexinfo_t r_skytexinfo[6]; -extern cvar_t gl_skyboxname; - char skyname[64]; /* @@ -129,7 +127,7 @@ char skyname[64]; R_LoadSkyBox ================ */ -void R_LoadSkyBox (void) +void SWR_LoadSkyBox (void) { #ifdef Q2BSPS void *Mod_LoadWall(char *name); @@ -167,7 +165,7 @@ void SWR_SetSky (char *name, float rotate, vec3_t axis) r_skytexinfo[i].texture = NULL; } - R_LoadSkyBox(); + SWR_LoadSkyBox(); } qboolean SWR_CheckSky (void) @@ -259,6 +257,12 @@ void R_InitSkyBox (void) Hunk_Check(); } +void SWR_Skyboxname_Callback(struct cvar_s *var, char *oldvalue) +{ + Q_strncpyz (skyname, var->string, sizeof(skyname)); + SWR_LoadSkyBox(); +} + /* ================ R_EmitSkyBox @@ -274,13 +278,6 @@ qboolean R_EmitSkyBox (void) if (r_skyframe == r_framecount) return true; // already set this frame - if (gl_skyboxname.modified) - { - Q_strncpyz (skyname, gl_skyboxname.string, sizeof(skyname)); - R_LoadSkyBox(); - gl_skyboxname.modified = false; - } - if (!*skyname) //none set return false; diff --git a/engine/sw/r_main.c b/engine/sw/r_main.c index 0d8918bc8..f26706ec1 100644 --- a/engine/sw/r_main.c +++ b/engine/sw/r_main.c @@ -204,8 +204,10 @@ void SWR_InitTextures (void) }*/ // callback declares -extern cvar_t crosshaircolor; +extern cvar_t crosshaircolor, r_skyboxname, r_menutint; void SWCrosshaircolor_Callback(struct cvar_s *var, char *oldvalue); +void SWR_Skyboxname_Callback(struct cvar_s *var, char *oldvalue); +void SWR_Menutint_Callback(struct cvar_s *var, char *oldvalue); void SWR_DeInit (void) { @@ -213,6 +215,8 @@ void SWR_DeInit (void) Cmd_RemoveCommand ("pointfile"); Cvar_Unhook(&crosshaircolor); + Cvar_Unhook(&r_skyboxname); + Cvar_Unhook(&r_menutint); SWDraw_Shutdown(); D_Shutdown(); @@ -235,6 +239,8 @@ void SWR_Init (void) Cmd_AddRemCommand ("timerefresh", SWR_TimeRefresh_f); Cvar_Hook(&crosshaircolor, SWCrosshaircolor_Callback); + Cvar_Hook(&r_skyboxname, SWR_Skyboxname_Callback); + Cvar_Hook(&r_menutint, SWR_Menutint_Callback); if (!r_maxedges.value) Cvar_SetValue (&r_maxedges, (float)NUMSTACKEDGES);