1
0
Fork 0
forked from fte/fteqw

cl_sbar/vid_conautoscale/vid_conwidth/vid_conheight/gl_font/gl_fontedgeclamp/gl_smoothfont/gl_conback/fov/viewsize changed to callbacks, needs testing.. hopefully increases fps a bit

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2211 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2006-04-15 06:57:13 +00:00
parent 3fd1a224e3
commit 960b2b8d96
10 changed files with 228 additions and 193 deletions

View file

@ -31,6 +31,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define WINAVI
#endif
// callbacks
void CL_Sbar_Callback(struct cvar_s *var, char *oldvalue);
// we need to declare some mouse variables here, because the menu system
// references them even when on a unix system.
@ -45,7 +48,7 @@ cvar_t cl_timeout = SCVAR("cl_timeout", "60");
cvar_t cl_shownet = SCVAR("cl_shownet","0"); // can be 0, 1, or 2
cvar_t cl_sbar = SCVARF("cl_sbar", "0", CVAR_ARCHIVE);
cvar_t cl_sbar = SCVARFC("cl_sbar", "0", CVAR_ARCHIVE, CL_Sbar_Callback);
cvar_t cl_hudswap = SCVARF("cl_hudswap", "0", CVAR_ARCHIVE);
cvar_t cl_maxfps = SCVARF("cl_maxfps", "1000", CVAR_ARCHIVE);
cvar_t cl_nopext = SCVARF("cl_nopext", "0", CVAR_ARCHIVE);

View file

@ -96,7 +96,6 @@ float scr_conlines; // lines of console to display
qboolean scr_con_forcedraw;
float oldscreensize, oldfov;
extern cvar_t scr_viewsize;
extern cvar_t scr_fov;
extern cvar_t scr_conspeed;
@ -837,6 +836,43 @@ float CalcFov (float fov_x, float width, float height)
return a;
}
void SCR_Fov_Callback (struct cvar_s *var, char *oldvalue)
{
if (var->value < 10)
{
Cvar_ForceSet (var, "10");
return;
}
if (var->value > 170)
{
Cvar_ForceSet (var, "170");
return;
}
vid.recalc_refdef = true;
}
void SCR_Viewsize_Callback (struct cvar_s *var, char *oldvalue)
{
if (var->value < 30)
{
Cvar_ForceSet (var, "30");
return;
}
if (var->value > 120)
{
Cvar_ForceSet (var, "120");
return;
}
vid.recalc_refdef = true;
}
void CL_Sbar_Callback(struct cvar_s *var, char *oldvalue)
{
vid.recalc_refdef = true;
}
/*
=================
SCR_CalcRefdef
@ -853,7 +889,6 @@ void SCR_CalcRefdef (void)
scr_fullupdate = 0; // force a background redraw
vid.recalc_refdef = 0;
scr_viewsize.modified = false;
// force the status bar to redraw
Sbar_Changed ();
@ -861,17 +896,6 @@ void SCR_CalcRefdef (void)
//========================================
r_refdef.flags = 0;
// bound viewsize
if (scr_viewsize.value < 30)
Cvar_Set (&scr_viewsize,"30");
if (scr_viewsize.value > 120)
Cvar_Set (&scr_viewsize,"120");
// bound field of view
if (scr_fov.value < 10)
Cvar_Set (&scr_fov,"10");
if (scr_fov.value > 170)
Cvar_Set (&scr_fov,"170");
// intermission is always full screen
if (cl.intermission)
@ -1045,7 +1069,6 @@ Keybinding command
void SCR_SizeUp_f (void)
{
Cvar_SetValue (&scr_viewsize,scr_viewsize.value+10);
vid.recalc_refdef = 1;
}
@ -1059,7 +1082,6 @@ Keybinding command
void SCR_SizeDown_f (void)
{
Cvar_SetValue (&scr_viewsize,scr_viewsize.value-10);
vid.recalc_refdef = 1;
}
//============================================================================

View file

@ -26,6 +26,8 @@ unsigned int *d_8to32table = d_8to24bgrtable; //palette lookups while rendering
extern int gl_anisotropy_factor;
// callbacks used for cvars
void SCR_Viewsize_Callback (struct cvar_s *var, char *oldvalue);
void SCR_Fov_Callback (struct cvar_s *var, char *oldvalue);
#if defined(RGLQUAKE)
void GL_Texturemode_Callback (struct cvar_s *var, char *oldvalue);
#endif
@ -103,13 +105,14 @@ static cvar_t vid_desktopsettings = SCVARF("vid_desktopsettings", "0", CVAR_ARCH
#if defined(RGLQUAKE)
cvar_t gl_texturemode = SCVARFC("gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST", CVAR_ARCHIVE|CVAR_RENDERERCALLBACK, GL_Texturemode_Callback);
cvar_t gl_conback = SCVARF("gl_conback", "", CVAR_RENDERERCALLBACK);
cvar_t gl_font = SCVARF("gl_font", "", CVAR_RENDERERCALLBACK);
//gl blends. Set this to 1 to stop the outside of your conchars from being visible
cvar_t gl_fontedgeclamp = SCVAR("gl_fontedgeclamp", "0");
cvar_t gl_smoothfont = SCVAR("gl_smoothfont", "1");
#endif
cvar_t gl_motionblur = SCVARF("gl_motionblur", "0", CVAR_ARCHIVE);
cvar_t gl_motionblurscale = SCVAR("gl_motionblurscale", "1");
cvar_t gl_fontedgeclamp = SCVAR("gl_fontedgeclamp", "0"); //gl blends. Set this to 1 to stop the outside of your conchars from being visible
cvar_t gl_font = SCVAR("gl_font", "");
cvar_t gl_conback = SCVAR("gl_conback", "");
cvar_t gl_smoothfont = SCVAR("gl_smoothfont", "1");
cvar_t gl_part_flame = SCVAR("gl_part_flame", "1");
cvar_t r_part_rain = SCVARF("r_part_rain", "0", CVAR_ARCHIVE);
@ -123,9 +126,9 @@ cvar_t r_shadow_bumpscale_basetexture = SCVAR("r_shadow_bumpscale_basetexture",
cvar_t r_shadow_bumpscale_bumpmap = SCVAR("r_shadow_bumpscale_bumpmap", "10");
cvar_t gl_nocolors = SCVAR("gl_nocolors","0");
cvar_t gl_load24bit = SCVARF("gl_load24bit", "1", CVAR_ARCHIVE);
cvar_t vid_conwidth = SCVARF("vid_conwidth", "640", CVAR_ARCHIVE);
cvar_t vid_conwidth = SCVARF("vid_conwidth", "640", CVAR_ARCHIVE|CVAR_RENDERERCALLBACK);
cvar_t vid_conheight = SCVARF("vid_conheight", "480", CVAR_ARCHIVE);
cvar_t vid_conautoscale = SCVARF("vid_conautoscale", "0", CVAR_ARCHIVE);
cvar_t vid_conautoscale = SCVARF("vid_conautoscale", "0", CVAR_ARCHIVE|CVAR_RENDERERCALLBACK);
cvar_t gl_nobind = SCVAR("gl_nobind", "0");
cvar_t gl_max_size = SCVAR("gl_max_size", "1024");
cvar_t gl_picmip = SCVAR("gl_picmip", "0");
@ -172,8 +175,8 @@ cvar_t scr_centersbar = SCVAR("scr_centersbar", "0");
cvar_t scr_consize = SCVAR("scr_consize", "0.5");
cvar_t scr_conalpha = SCVAR("scr_conalpha", "0.7");
cvar_t scr_viewsize = SCVARF("viewsize","100", CVAR_ARCHIVE);
cvar_t scr_fov = SCVARF("fov","90", CVAR_ARCHIVE); // 10 - 170
cvar_t scr_viewsize = SCVARFC("viewsize","100", CVAR_ARCHIVE, SCR_Viewsize_Callback);
cvar_t scr_fov = SCVARFC("fov","90", CVAR_ARCHIVE, SCR_Fov_Callback); // 10 - 170
cvar_t scr_conspeed = SCVAR("scr_conspeed","300");
cvar_t scr_centertime = SCVAR("scr_centertime","2");
cvar_t scr_showram = SCVAR("showram","1");

View file

@ -1121,6 +1121,12 @@ void Cvar_Unhook(cvar_t *cvar)
cvar->callback = NULL;
}
void Cvar_ForceCallback(cvar_t *var)
{
if (var->callback)
var->callback(var, var->string);
}
void Cvar_ApplyCallbacks(int callbackflag)
{
cvar_group_t *grp;

View file

@ -137,6 +137,9 @@ void Cvar_Hook(cvar_t *cvar, void (*callback) (struct cvar_s *var, char *oldvalu
void Cvar_Unhook(cvar_t *cvar);
//unhook a cvar
void Cvar_ForceCallback(cvar_t *cvar);
// force a cvar callback
void Cvar_ApplyCallbacks(int callbackflag);
//forces callbacks to be ran for given flags

View file

@ -61,7 +61,7 @@ extern cvar_t gl_lerpimages;
extern cvar_t gl_picmip2d;
extern cvar_t r_drawdisk;
extern cvar_t gl_compress;
extern cvar_t gl_font, gl_conback, gl_smoothfont, gl_fontedgeclamp;
extern cvar_t gl_smoothfont, gl_fontedgeclamp;
extern cvar_t gl_texturemode;
extern cvar_t cl_noblink;
@ -905,11 +905,6 @@ TRACE(("dbg: GLDraw_ReInit: Allocating upload buffers\n"));
TRACE(("dbg: GLDraw_ReInit: loaded charset\n"));
gl_font.modified = true;
gl_smoothfont.modified = 1;
TRACE(("dbg: GLDraw_ReInit: GL_BeginRendering\n"));
GL_BeginRendering (&glx, &gly, &glwidth, &glheight);
TRACE(("dbg: GLDraw_ReInit: SCR_DrawLoading\n"));
@ -1104,8 +1099,6 @@ TRACE(("dbg: GLDraw_ReInit: Allocating upload buffers\n"));
custom_conback->width = vid.conwidth;
custom_conback->height = vid.conheight;
gl_conback.modified = true;
// free loaded console
Hunk_FreeToLowMark (start);
@ -2260,6 +2253,67 @@ void GLDraw_EndDisc (void)
{
}
// conback/font callbacks
void GL_Smoothfont_Callback(struct cvar_s *var, char *oldvalue)
{
GL_Bind(char_texture);
if (var->value)
{
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
else
{
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
}
void GL_Fontedgeclamp_Callback(struct cvar_s *var, char *oldvalue)
{
if (var->value)
char_instep = custom_char_instep;
else
char_instep = 0;
}
void GL_Font_Callback(struct cvar_s *var, char *oldvalue)
{
if (!*var->string
|| (!(char_texture=Mod_LoadHiResTexture(var->string, "fonts", false, true, true))
&& !(char_texture=Mod_LoadHiResTexture(var->string, "charsets", false, true, true))))
{
char_texture = default_char_texture;
custom_char_instep = default_char_instep;
}
else
custom_char_instep = 0.5f/((image_width+image_height)/2);
GL_Smoothfont_Callback(&gl_smoothfont, "");
GL_Fontedgeclamp_Callback(&gl_fontedgeclamp, "");
}
void GL_Conback_Callback(struct cvar_s *var, char *oldvalue)
{
int newtex = 0;
#ifdef Q3SHADERS
if (*var->string && (shader_console = R_RegisterCustom(var->string, NULL)))
{
conback = default_conback;
}
else
#endif
if (!*var->string || !(newtex=Mod_LoadHiResTexture(var->string, "conbacks", false, true, true)))
{
conback = default_conback;
}
else
{
conback = custom_conback;
((glpic_t *)conback->data)->texnum = newtex;
}
}
/*
================
GL_Set2D
@ -2297,69 +2351,6 @@ void GL_Set2D (void)
qglColor4f (1,1,1,1);
if (gl_font.modified)
{
gl_font.modified = 0;
if (!*gl_font.string
|| (!(char_texture=Mod_LoadHiResTexture(gl_font.string, "fonts", false, true, true))
&& !(char_texture=Mod_LoadHiResTexture(gl_font.string, "charsets", false, true, true))))
{
char_texture = default_char_texture;
custom_char_instep = default_char_instep;
}
else
custom_char_instep = 0.5f/((image_width+image_height)/2);
gl_smoothfont.modified = true;
gl_fontedgeclamp.modified = true;
}
if (gl_conback.modified)
{
int newtex = 0;
gl_conback.modified = 0;
#ifdef Q3SHADERS
if (*gl_conback.string && (shader_console = R_RegisterCustom(gl_conback.string, NULL)))
{
conback = default_conback;
}
else
#endif
if (!*gl_conback.string || !(newtex=Mod_LoadHiResTexture(gl_conback.string, "conbacks", false, true, true)))
{
conback = default_conback;
}
else
{
conback = custom_conback;
((glpic_t *)conback->data)->texnum = newtex;
}
}
if (gl_fontedgeclamp.modified)
{
if (gl_fontedgeclamp.value)
char_instep = custom_char_instep;
else
char_instep = 0;
gl_fontedgeclamp.modified = false;
}
if (gl_smoothfont.modified)
{
gl_smoothfont.modified = false;
GL_Bind(char_texture);
if (gl_smoothfont.value)
{
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
else
{
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
}
r_refdef.time = realtime;
}

View file

@ -655,15 +655,24 @@ if (!data)
void GLR_TimeRefresh_f (void);
extern cvar_t gl_bump;
extern cvar_t r_stains, r_stainfadetime, r_stainfadeammount, r_menutint;
extern cvar_t r_stains, r_stainfadetime, r_stainfadeammount;
// callback defines
extern cvar_t gl_conback, gl_font, gl_smoothfont, gl_fontedgeclamp, r_menutint;
extern cvar_t vid_conautoscale, vid_conheight, vid_conwidth;
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 GL_Conback_Callback (struct cvar_s *var, char *oldvalue);
void GL_Font_Callback (struct cvar_s *var, char *oldvalue);
void GL_Smoothfont_Callback (struct cvar_s *var, char *oldvalue);
void GL_Fontedgeclamp_Callback (struct cvar_s *var, char *oldvalue);
void GLVID_Conwidth_Callback(struct cvar_s *var, char *oldvalue);
void GLVID_Conautoscale_Callback(struct cvar_s *var, char *oldvalue);
void GLVID_Conheight_Callback(struct cvar_s *var, char *oldvalue);
void GLR_DeInit (void)
{
@ -678,6 +687,13 @@ void GLR_DeInit (void)
Cvar_Unhook(&crosshaircolor);
Cvar_Unhook(&r_skyboxname);
Cvar_Unhook(&r_menutint);
Cvar_Unhook(&gl_conback);
Cvar_Unhook(&gl_font);
Cvar_Unhook(&gl_smoothfont);
Cvar_Unhook(&gl_fontedgeclamp);
Cvar_Unhook(&vid_conautoscale);
Cvar_Unhook(&vid_conheight);
Cvar_Unhook(&vid_conwidth);
GLDraw_DeInit();
@ -696,6 +712,13 @@ void GLR_Init (void)
Cvar_Hook(&crosshaircolor, GLCrosshaircolor_Callback);
Cvar_Hook(&r_skyboxname, GLR_Skyboxname_Callback);
Cvar_Hook(&r_menutint, GLR_Menutint_Callback);
Cvar_Hook(&gl_conback, GL_Conback_Callback);
Cvar_Hook(&gl_font, GL_Font_Callback);
Cvar_Hook(&gl_smoothfont, GL_Smoothfont_Callback);
Cvar_Hook(&gl_fontedgeclamp, GL_Fontedgeclamp_Callback);
Cvar_Hook(&vid_conautoscale, GLVID_Conautoscale_Callback);
Cvar_Hook(&vid_conheight, GLVID_Conheight_Callback);
Cvar_Hook(&vid_conwidth, GLVID_Conwidth_Callback);
R_InitBubble();

View file

@ -38,9 +38,6 @@ extern qboolean scr_initialized;
extern float oldsbar;
extern qboolean scr_drawloading;
extern float oldfov;
extern int scr_chatmode;
extern cvar_t scr_chatmodecvar;
@ -116,6 +113,79 @@ void RSpeedShow(void)
}
}
// console size manipulation callbacks
void GLVID_Console_Resize(void)
{
extern cvar_t vid_conwidth, vid_conheight;
vid.width = vid.conwidth = vid_conwidth.value;
vid.height = vid.conheight = vid_conheight.value;
vid.recalc_refdef = true;
Con_CheckResize();
#ifdef PLUGINS
Plug_ResChanged();
#endif
}
void GLVID_Conheight_Callback(struct cvar_s *var, char *oldvalue)
{
if (var->value > 1536) //anything higher is unreadable.
{
Cvar_ForceSet(var, "1536");
return;
}
if (var->value < 200) //lower would be wrong
{
Cvar_ForceSet(var, "200");
return;
}
GLVID_Console_Resize();
}
void GLVID_Conwidth_Callback(struct cvar_s *var, char *oldvalue)
{
//let let the user be too crazy
if (var->value > 2048) //anything higher is unreadable.
{
Cvar_ForceSet(var, "2048");
return;
}
if (var->value < 320) //lower would be wrong
{
Cvar_ForceSet(var, "320");
return;
}
GLVID_Console_Resize();
}
void GLVID_Conautoscale_Callback(struct cvar_s *var, char *oldvalue)
{
extern cvar_t vid_conwidth, vid_conheight;
float xratio, yratio = 0;
xratio = var->value;
if (xratio > 0)
{
char *s = strchr(var->string, ' ');
if (s)
yratio = atof(s + 1);
if (yratio <= 0)
yratio = xratio;
xratio = 1 / xratio;
yratio = 1 / yratio;
Cvar_SetValue(&vid_conwidth, glwidth * xratio);
Cvar_SetValue(&vid_conheight, glheight * yratio);
}
}
/*
==================
SCR_UpdateScreen
@ -130,7 +200,7 @@ needs almost the entire 256k of stack space!
void GLSCR_UpdateScreen (void)
{
extern cvar_t vid_conwidth, vid_conheight, gl_texturemode, vid_conautoscale;
extern cvar_t vid_conheight;
int uimenu;
#ifdef TEXTEDITOR
extern qboolean editormodal;
@ -144,60 +214,6 @@ void GLSCR_UpdateScreen (void)
return;
}
if (vid_conautoscale.modified)
{
float xratio, yratio = 0;
xratio = vid_conautoscale.value;
if (xratio > 0)
{
char *s = strchr(vid_conautoscale.string, ' ');
if (s)
yratio = atof(s + 1);
if (yratio <= 0)
yratio = xratio;
xratio = 1 / xratio;
yratio = 1 / yratio;
Cvar_SetValue(&vid_conwidth, glwidth * xratio);
Cvar_SetValue(&vid_conheight, glheight * yratio);
}
vid_conautoscale.modified = false;
}
if (vid_conwidth.modified || vid_conheight.modified)
{
//let let the user be too crazy
if (vid_conwidth.value > 2048) //anything higher is unreadable.
Cvar_Set(&vid_conwidth, "2048");
if (vid_conheight.value > 1536) //anything higher is unreadable.
Cvar_Set(&vid_conheight, "1536");
if (vid_conwidth.value < 320) //lower would be wrong
Cvar_Set(&vid_conwidth, "320");
if (vid_conheight.value < 200) //lower would be wrong
Cvar_Set(&vid_conheight, "200");
vid_conwidth.modified = false;
vid_conheight.modified = false;
// vid.width = vid.conwidth = (glwidth - 320) * gl_2dscale.value + 320;
// vid.height = vid.conheight = (glheight - 240) * gl_2dscale.value + 240;
vid.width = vid.conwidth = vid_conwidth.value;
vid.height = vid.conheight = vid_conheight.value;
vid.recalc_refdef = true;
Con_CheckResize();
#ifdef PLUGINS
Plug_ResChanged();
#endif
GL_Set2D();
}
vid.numpages = 2 + gl_triplebuffer.value;
scr_copytop = 0;
@ -233,12 +249,6 @@ void GLSCR_UpdateScreen (void)
uimenu = 0;
#endif
if (oldsbar != cl_sbar.value) {
oldsbar = cl_sbar.value;
vid.recalc_refdef = true;
}
GL_BeginRendering (&glx, &gly, &glwidth, &glheight);
#ifdef TEXTEDITOR
@ -276,13 +286,7 @@ void GLSCR_UpdateScreen (void)
//
// determine size of refresh window
//
if (oldfov != scr_fov.value)
{
oldfov = scr_fov.value;
vid.recalc_refdef = true;
}
if (vid.recalc_refdef || scr_viewsize.modified)
if (vid.recalc_refdef)
SCR_CalcRefdef ();
//

View file

@ -399,8 +399,6 @@ qboolean VID_SetWindowedMode (rendererstate_t *info)
else
{
vid.conwidth = 640;
vid_conwidth.modified = true; //make it reapplied
vid_conautoscale.modified = true;
}
vid.conwidth &= 0xfff8; // make it a multiple of eight
@ -422,8 +420,6 @@ qboolean VID_SetWindowedMode (rendererstate_t *info)
vid.conwidth = info->width;
vid.width = vid.conwidth;
vid.height = vid.conheight;
vid_conwidth.modified = true;
vid_conautoscale.modified = true;
vid.numpages = 2;
@ -542,8 +538,6 @@ qboolean VID_SetFullDIBMode (rendererstate_t *info)
vid.conwidth = info->width;
vid.width = vid.conwidth;
vid.height = vid.conheight;
vid_conwidth.modified = true;
vid_conautoscale.modified = true;
vid.numpages = 2;
@ -1419,8 +1413,11 @@ LONG WINAPI GLMainWndProc (
{
WindowRect.right = ((short*)&lParam)[0] - WindowRect.left;
WindowRect.bottom = ((short*)&lParam)[1] - WindowRect.top;
vid_conwidth.modified = true; //make it reapplied
vid_conautoscale.modified = true;
// force width/height to be updated
glwidth = WindowRect.right - WindowRect.left;
glheight = WindowRect.bottom - WindowRect.top;
Cvar_ForceCallback(&vid_conautoscale);
Cvar_ForceCallback(&vid_conwidth);
}
break;

View file

@ -33,9 +33,6 @@ extern qboolean scr_initialized;
extern float oldsbar;
extern qboolean scr_drawloading;
extern float oldfov, oldscreensize;
extern int scr_chatmode;
extern cvar_t scr_chatmodecvar;
@ -85,20 +82,6 @@ void SWSCR_UpdateScreen (void)
uimenu = 0;
#endif
//
// check for vid changes
//
if (oldfov != scr_fov.value)
{
oldfov = scr_fov.value;
vid.recalc_refdef = true;
}
if (oldsbar != cl_sbar.value)
{
oldsbar = cl_sbar.value;
vid.recalc_refdef = true;
}
#ifdef TEXTEDITOR
if (editormodal)
{
@ -129,7 +112,7 @@ void SWSCR_UpdateScreen (void)
return;
}
if (vid.recalc_refdef || scr_viewsize.modified)
if (vid.recalc_refdef)
{
// something changed, so reorder the screen
SCR_CalcRefdef ();