1
0
Fork 0
forked from fte/fteqw

internal cleanup, r_menutint and r_skybox use callbacks

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2210 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2006-04-15 05:28:44 +00:00
parent 571ea11411
commit 3fd1a224e3
8 changed files with 83 additions and 93 deletions

View file

@ -287,7 +287,7 @@ struct mleaf_s *GLMod_PointInLeaf (struct model_s *model, float *p);
void GLMod_Think (void); void GLMod_Think (void);
void GLMod_NowLoadExternal(void); void GLMod_NowLoadExternal(void);
void GLR_WipeStains(void); void GLR_WipeStains(void);
void R_LoadSkys (void); void GLR_LoadSkys (void);
#endif #endif
#if defined(SWQUAKE) #if defined(SWQUAKE)

View file

@ -245,11 +245,11 @@ void R_BulletenForce_f (void);
rendererstate_t currentrendererstate; 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_fastsky = SCVAR("r_fastsky", "0");
cvar_t r_fastskycolour = SCVAR("r_fastskycolour", "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) #if defined(RGLQUAKE)
cvar_t gl_schematics = SCVAR("gl_schematics","0"); cvar_t gl_schematics = SCVAR("gl_schematics","0");
@ -496,7 +496,7 @@ void Renderer_Init(void)
Cvar_Register (&vid_desktopsettings, VIDCOMMANDGROUP); Cvar_Register (&vid_desktopsettings, VIDCOMMANDGROUP);
Cvar_Register (&gl_skyboxname, GRAPHICALNICETIES); Cvar_Register (&r_skyboxname, GRAPHICALNICETIES);
Cvar_Register(&r_dodgytgafiles, "Bug fixes"); Cvar_Register(&r_dodgytgafiles, "Bug fixes");
Cvar_Register(&r_dodgypcxfiles, "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")); TRACE(("dbg: R_ApplyRenderer: old renderer closed\n"));
gl_skyboxname.modified = true;
pmove.numphysent = 0; pmove.numphysent = 0;
if (qrenderer) //graphics stuff only when not dedicated if (qrenderer) //graphics stuff only when not dedicated

View file

@ -2008,22 +2008,15 @@ Draw_FadeScreen
================ ================
*/ */
vec3_t fadecolor; vec3_t fadecolor;
vec3_t fadecolorreal;
int faderender; int faderender;
int fademodified;
void GLDraw_FadeScreen (void) void GLR_Menutint_Callback (struct cvar_s *var, char *oldvalue)
{
extern cvar_t r_menutint, 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 // parse r_menutint and clear defaults
faderender = GL_DST_COLOR; faderender = GL_DST_COLOR;
if (r_menutint.string[0]) if (var->string[0])
SCR_StringToRGB(r_menutint.string, fadecolor, 1); SCR_StringToRGB(var->string, fadecolor, 1);
else else
faderender = 0; faderender = 0;
@ -2046,10 +2039,13 @@ void GLDraw_FadeScreen (void)
fadecolor[2] = -(fadecolor[2]); fadecolor[2] = -(fadecolor[2]);
} }
} }
fademodified = r_menutint.modified;
} }
void GLDraw_FadeScreen (void)
{
extern cvar_t gl_menutint_shader;
extern int scenepp_texture, scenepp_mt_program, scenepp_mt_parm_colorf, scenepp_mt_parm_inverti;
if (!faderender) if (!faderender)
return; return;

View file

@ -655,13 +655,15 @@ if (!data)
void GLR_TimeRefresh_f (void); void GLR_TimeRefresh_f (void);
extern cvar_t gl_bump; 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 // 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 GLCrosshairimage_Callback(struct cvar_s *var, char *oldvalue);
void GLCrosshair_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 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) void GLR_DeInit (void)
{ {
@ -674,6 +676,8 @@ void GLR_DeInit (void)
Cvar_Unhook(&crosshair); Cvar_Unhook(&crosshair);
Cvar_Unhook(&crosshairimage); Cvar_Unhook(&crosshairimage);
Cvar_Unhook(&crosshaircolor); Cvar_Unhook(&crosshaircolor);
Cvar_Unhook(&r_skyboxname);
Cvar_Unhook(&r_menutint);
GLDraw_DeInit(); GLDraw_DeInit();
@ -690,6 +694,8 @@ void GLR_Init (void)
Cvar_Hook(&crosshair, GLCrosshair_Callback); Cvar_Hook(&crosshair, GLCrosshair_Callback);
Cvar_Hook(&crosshairimage, GLCrosshairimage_Callback); Cvar_Hook(&crosshairimage, GLCrosshairimage_Callback);
Cvar_Hook(&crosshaircolor, GLCrosshaircolor_Callback); Cvar_Hook(&crosshaircolor, GLCrosshaircolor_Callback);
Cvar_Hook(&r_skyboxname, GLR_Skyboxname_Callback);
Cvar_Hook(&r_menutint, GLR_Menutint_Callback);
R_InitBubble(); R_InitBubble();
@ -1043,7 +1049,7 @@ TRACE(("dbg: GLR_NewMap: figuring out skys and mirrors\n"));
} }
TRACE(("dbg: GLR_NewMap: that skybox thang\n")); TRACE(("dbg: GLR_NewMap: that skybox thang\n"));
//#ifdef QUAKE2 //#ifdef QUAKE2
R_LoadSkys (); GLR_LoadSkys ();
//#endif //#endif
TRACE(("dbg: GLR_NewMap: ui\n")); TRACE(("dbg: GLR_NewMap: ui\n"));
#ifdef VM_UI #ifdef VM_UI

View file

@ -47,12 +47,11 @@ qboolean usingskybox;
msurface_t *warpface; msurface_t *warpface;
extern cvar_t gl_skyboxname; extern cvar_t r_skyboxname;
extern cvar_t gl_skyboxdist; extern cvar_t gl_skyboxdist;
extern cvar_t r_fastsky; extern cvar_t r_fastsky;
extern cvar_t r_fastskycolour; extern cvar_t r_fastskycolour;
char defaultskybox[MAX_QPATH]; char defaultskybox[MAX_QPATH];
qboolean reloadskybox;
int skyboxtex[6]; int skyboxtex[6];
@ -301,15 +300,15 @@ static char *skyname_pattern[] = {
"gfx/env/%s%s" "gfx/env/%s%s"
}; };
void R_LoadSkys (void) void GLR_LoadSkys (void)
{ {
int i; int i;
char name[MAX_QPATH]; char name[MAX_QPATH];
char *boxname; char *boxname;
int p, s; int p, s;
if (*gl_skyboxname.string) if (*r_skyboxname.string)
boxname = gl_skyboxname.string; //user forced boxname = r_skyboxname.string; //user forced
else else
boxname = defaultskybox; boxname = defaultskybox;
@ -350,7 +349,6 @@ void R_LoadSkys (void)
break; break;
} }
} }
reloadskybox = false;
} }
@ -358,13 +356,17 @@ qboolean GLR_CheckSky()
{ {
return true; 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 void GLR_SetSky(char *name, float rotate, vec3_t axis) //called from the client code, once per level
{ {
Q_strncpyz(defaultskybox, name, sizeof(defaultskybox)); Q_strncpyz(defaultskybox, name, sizeof(defaultskybox));
if (!*gl_skyboxname.string) //don't override a user's settings if (!*r_skyboxname.string) //don't override a user's settings
{ GLR_Skyboxname_Callback(&r_skyboxname, "");
reloadskybox = true;
}
skyrotate = rotate; skyrotate = rotate;
VectorCopy(axis, skyaxis); VectorCopy(axis, skyaxis);
@ -772,14 +774,6 @@ void R_ClearSkyBox (void)
usingskybox = false; usingskybox = false;
return; 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]) if (!skyboxtex[0] || !skyboxtex[1] || !skyboxtex[2] || !skyboxtex[3] || !skyboxtex[4] || !skyboxtex[5])
{ {

View file

@ -16,15 +16,11 @@ qbyte *pal555to8;
int swzpal[TRANS_LEVELS][256]; int swzpal[TRANS_LEVELS][256];
// menutint // menutint
palremap_t *RebuildMenuTint(void);
palremap_t *mtpalremap; palremap_t *mtpalremap;
// IB remap // IB remap
palremap_t *ib_remap; palremap_t *ib_remap;
extern cvar_t r_menutint;
int mtmodified;
#define palette host_basepal #define palette host_basepal
#define _abs(x) ((x)*(x)) #define _abs(x) ((x)*(x))
@ -44,7 +40,6 @@ void D_ShutdownTrans(void)
} }
mtpalremap = NULL; mtpalremap = NULL;
mtmodified = 0;
ib_remap = NULL; ib_remap = NULL;
} }
@ -57,7 +52,6 @@ void D_InitTrans(void)
srctable = swzpal[0]; srctable = swzpal[0];
dsttable = swzpal[TRANS_MAX]; dsttable = swzpal[TRANS_MAX];
mtpalremap = RebuildMenuTint();
ib_remap = D_IdentityRemap(); ib_remap = D_IdentityRemap();
} }
@ -413,12 +407,12 @@ palremap_t *D_GetPaletteRemap(int red, int green, int blue, qboolean desaturate,
return palremaps + deref; return palremaps + deref;
} }
palremap_t *RebuildMenuTint(void) palremap_t *RebuildMenuTint(struct cvar_s *var)
{ {
vec3_t rgb; vec3_t rgb;
if (r_menutint.string[0]) if (var->string[0])
SCR_StringToRGB(r_menutint.string, rgb, 1); SCR_StringToRGB(var->string, rgb, 1);
else else
return NULL; return NULL;
@ -443,17 +437,16 @@ void D_DereferenceRemap(palremap_t *palremap)
} }
} }
qbyte *D_GetMenuTintPal(void) void SWR_Menutint_Callback(struct cvar_s *var, char *oldvalue)
{
if (mtmodified != r_menutint.modified)
{ {
if (mtpalremap) if (mtpalremap)
D_DereferenceRemap(mtpalremap); D_DereferenceRemap(mtpalremap);
mtpalremap = RebuildMenuTint(); mtpalremap = RebuildMenuTint(var);
mtmodified = r_menutint.modified;
} }
qbyte *D_GetMenuTintPal(void)
{
if (mtpalremap && mtpalremap != palremaps) if (mtpalremap && mtpalremap != palremaps)
return mtpalremap->pal; return mtpalremap->pal;
else else

View file

@ -120,8 +120,6 @@ static char *suf[6] = {"rt", "bk", "lf", "ft", "up", "dn"};
int r_skysideimage[6] = {5, 2, 4, 1, 0, 3}; int r_skysideimage[6] = {5, 2, 4, 1, 0, 3};
extern mtexinfo_t r_skytexinfo[6]; extern mtexinfo_t r_skytexinfo[6];
extern cvar_t gl_skyboxname;
char skyname[64]; char skyname[64];
/* /*
@ -129,7 +127,7 @@ char skyname[64];
R_LoadSkyBox R_LoadSkyBox
================ ================
*/ */
void R_LoadSkyBox (void) void SWR_LoadSkyBox (void)
{ {
#ifdef Q2BSPS #ifdef Q2BSPS
void *Mod_LoadWall(char *name); 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_skytexinfo[i].texture = NULL;
} }
R_LoadSkyBox(); SWR_LoadSkyBox();
} }
qboolean SWR_CheckSky (void) qboolean SWR_CheckSky (void)
@ -259,6 +257,12 @@ void R_InitSkyBox (void)
Hunk_Check(); Hunk_Check();
} }
void SWR_Skyboxname_Callback(struct cvar_s *var, char *oldvalue)
{
Q_strncpyz (skyname, var->string, sizeof(skyname));
SWR_LoadSkyBox();
}
/* /*
================ ================
R_EmitSkyBox R_EmitSkyBox
@ -274,13 +278,6 @@ qboolean R_EmitSkyBox (void)
if (r_skyframe == r_framecount) if (r_skyframe == r_framecount)
return true; // already set this frame 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 if (!*skyname) //none set
return false; return false;

View file

@ -204,8 +204,10 @@ void SWR_InitTextures (void)
}*/ }*/
// callback declares // callback declares
extern cvar_t crosshaircolor; extern cvar_t crosshaircolor, r_skyboxname, r_menutint;
void SWCrosshaircolor_Callback(struct cvar_s *var, char *oldvalue); 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) void SWR_DeInit (void)
{ {
@ -213,6 +215,8 @@ void SWR_DeInit (void)
Cmd_RemoveCommand ("pointfile"); Cmd_RemoveCommand ("pointfile");
Cvar_Unhook(&crosshaircolor); Cvar_Unhook(&crosshaircolor);
Cvar_Unhook(&r_skyboxname);
Cvar_Unhook(&r_menutint);
SWDraw_Shutdown(); SWDraw_Shutdown();
D_Shutdown(); D_Shutdown();
@ -235,6 +239,8 @@ void SWR_Init (void)
Cmd_AddRemCommand ("timerefresh", SWR_TimeRefresh_f); Cmd_AddRemCommand ("timerefresh", SWR_TimeRefresh_f);
Cvar_Hook(&crosshaircolor, SWCrosshaircolor_Callback); Cvar_Hook(&crosshaircolor, SWCrosshaircolor_Callback);
Cvar_Hook(&r_skyboxname, SWR_Skyboxname_Callback);
Cvar_Hook(&r_menutint, SWR_Menutint_Callback);
if (!r_maxedges.value) if (!r_maxedges.value)
Cvar_SetValue (&r_maxedges, (float)NUMSTACKEDGES); Cvar_SetValue (&r_maxedges, (float)NUMSTACKEDGES);