cvar_t scr_loadingscreen_scale_base = {0, "scr_loadingscreen_scale_base","0", "0 = console pixels, 1 = video pixels"};
cvar_t scr_loadingscreen_scale_limit = {0, "scr_loadingscreen_scale_limit","0", "0 = no limit, 1 = until first edge hits screen edge, 2 = until last edge hits screen edge, 3 = until width hits screen width, 4 = until height hits screen height"};
cvar_t scr_loadingscreen_count = {0, "scr_loadingscreen_count","1", "number of loading screen files to use randomly (named loading.tga, loading2.tga, loading3.tga, ...)"};
+cvar_t scr_loadingscreen_firstforstartup = {0, "scr_loadingscreen_firstforstartup","0", "remove loading.tga from random scr_loadingscreen_count selection and only display it on client startup, 0 = normal, 1 = firstforstartup"};
cvar_t scr_loadingscreen_barcolor = {0, "scr_loadingscreen_barcolor", "0 0 1", "rgb color of loadingscreen progress bar"};
cvar_t scr_loadingscreen_barheight = {0, "scr_loadingscreen_barheight", "8", "the height of the loadingscreen progress bar"};
cvar_t scr_infobar_height = {0, "scr_infobar_height", "8", "the height of the infobar items"};
================
*/
-void SCR_BeginLoadingPlaque (void)
+void SCR_BeginLoadingPlaque (qboolean startup)
{
// save console log up to this point to log_file if it was set by configs
Log_Start();
Host_StartVideo();
- SCR_UpdateLoadingScreen(false);
+ SCR_UpdateLoadingScreen(false, startup);
}
//=============================================================================
Cvar_RegisterVariable (&scr_loadingscreen_scale_base);
Cvar_RegisterVariable (&scr_loadingscreen_scale_limit);
Cvar_RegisterVariable (&scr_loadingscreen_count);
+ Cvar_RegisterVariable (&scr_loadingscreen_firstforstartup);
Cvar_RegisterVariable (&scr_loadingscreen_barcolor);
Cvar_RegisterVariable (&scr_loadingscreen_barheight);
Cvar_RegisterVariable (&scr_infobar_height);
void SCR_UpdateLoadingScreenIfShown(void)
{
if(loadingscreendone)
- SCR_UpdateLoadingScreen(loadingscreencleared);
+ SCR_UpdateLoadingScreen(loadingscreencleared, false);
}
void SCR_PushLoadingScreen (qboolean redraw, const char *msg, float len_in_parent)
VID_Finish();
}
-void SCR_UpdateLoadingScreen (qboolean clear)
+void SCR_UpdateLoadingScreen (qboolean clear, qboolean startup)
{
keydest_t old_key_dest;
int old_key_consoleactive;
clear |= loadingscreencleared;
if(!loadingscreendone)
- loadingscreenpic_number = rand() % (scr_loadingscreen_count.integer > 1 ? scr_loadingscreen_count.integer : 1);
+ {
+ if(startup && scr_loadingscreen_firstforstartup.integer)
+ loadingscreenpic_number = 0;
+ else if(scr_loadingscreen_firstforstartup.integer)
+ if(scr_loadingscreen_count.integer > 1)
+ loadingscreenpic_number = rand() % (scr_loadingscreen_count.integer - 1) + 1;
+ else
+ loadingscreenpic_number = 0;
+ else
+ loadingscreenpic_number = rand() % (scr_loadingscreen_count.integer > 1 ? scr_loadingscreen_count.integer : 1);
+ }
if(clear)
SCR_ClearLoadingScreenTexture();
extern cvar_t cl_minfps_fade;
extern cvar_t cl_minfps_qualitymax;
extern cvar_t cl_minfps_qualitymin;
-extern cvar_t cl_minfps_qualitypower;
-extern cvar_t cl_minfps_qualityscale;
-extern cvar_t r_viewscale_fpsscaling;
-static double cl_updatescreen_rendertime = 0;
+extern cvar_t cl_minfps_qualitymultiply;
+extern cvar_t cl_minfps_qualityhysteresis;
+extern cvar_t cl_minfps_qualitystepmax;
+extern cvar_t cl_minfps_force;
static double cl_updatescreen_quality = 1;
void CL_UpdateScreen(void)
{
vec3_t vieworigin;
- double rendertime1;
- double drawscreenstart;
+ static double drawscreenstart = 0.0;
+ double drawscreendelta;
float conwidth, conheight;
- float f;
r_viewport_t viewport;
+ if(drawscreenstart)
+ {
+ drawscreendelta = Sys_DirtyTime() - drawscreenstart;
+ if (cl_minfps.value > 0 && (cl_minfps_force.integer || !(cls.timedemo || (cls.capturevideo.active && !cls.capturevideo.realtime))) && drawscreendelta >= 0 && drawscreendelta < 60)
+ {
+ // quality adjustment according to render time
+ double actualframetime;
+ double targetframetime;
+ double adjust;
+ double f;
+ double h;
+
+ // fade lastdrawscreentime
+ r_refdef.lastdrawscreentime += (drawscreendelta - r_refdef.lastdrawscreentime) * cl_minfps_fade.value;
+
+ // find actual and target frame times
+ actualframetime = r_refdef.lastdrawscreentime;
+ targetframetime = (1.0 / cl_minfps.value);
+
+ // we scale hysteresis by quality
+ h = cl_updatescreen_quality * cl_minfps_qualityhysteresis.value;
+
+ // calculate adjustment assuming linearity
+ f = cl_updatescreen_quality / actualframetime * cl_minfps_qualitymultiply.value;
+ adjust = (targetframetime - actualframetime) * f;
+
+ // one sided hysteresis
+ if(adjust > 0)
+ adjust = max(0, adjust - h);
+
+ // adjust > 0 if:
+ // (targetframetime - actualframetime) * f > h
+ // ((1.0 / cl_minfps.value) - actualframetime) * (cl_updatescreen_quality / actualframetime * cl_minfps_qualitymultiply.value) > (cl_updatescreen_quality * cl_minfps_qualityhysteresis.value)
+ // ((1.0 / cl_minfps.value) - actualframetime) * (cl_minfps_qualitymultiply.value / actualframetime) > cl_minfps_qualityhysteresis.value
+ // (1.0 / cl_minfps.value) * (cl_minfps_qualitymultiply.value / actualframetime) - cl_minfps_qualitymultiply.value > cl_minfps_qualityhysteresis.value
+ // (1.0 / cl_minfps.value) * (cl_minfps_qualitymultiply.value / actualframetime) > cl_minfps_qualityhysteresis.value + cl_minfps_qualitymultiply.value
+ // (1.0 / cl_minfps.value) / actualframetime > (cl_minfps_qualityhysteresis.value + cl_minfps_qualitymultiply.value) / cl_minfps_qualitymultiply.value
+ // (1.0 / cl_minfps.value) / actualframetime > 1.0 + cl_minfps_qualityhysteresis.value / cl_minfps_qualitymultiply.value
+ // cl_minfps.value * actualframetime < 1.0 / (1.0 + cl_minfps_qualityhysteresis.value / cl_minfps_qualitymultiply.value)
+ // actualframetime < 1.0 / cl_minfps.value / (1.0 + cl_minfps_qualityhysteresis.value / cl_minfps_qualitymultiply.value)
+ // actualfps > cl_minfps.value * (1.0 + cl_minfps_qualityhysteresis.value / cl_minfps_qualitymultiply.value)
+
+ // adjust < 0 if:
+ // (targetframetime - actualframetime) * f < 0
+ // ((1.0 / cl_minfps.value) - actualframetime) * (cl_updatescreen_quality / actualframetime * cl_minfps_qualitymultiply.value) < 0
+ // ((1.0 / cl_minfps.value) - actualframetime) < 0
+ // -actualframetime) < -(1.0 / cl_minfps.value)
+ // actualfps < cl_minfps.value
+
+ /*
+ Con_Printf("adjust UP if fps > %f, adjust DOWN if fps < %f\n",
+ cl_minfps.value * (1.0 + cl_minfps_qualityhysteresis.value / cl_minfps_qualitymultiply.value),
+ cl_minfps.value);
+ */
+
+ // don't adjust too much at once
+ adjust = bound(-cl_minfps_qualitystepmax.value, adjust, cl_minfps_qualitystepmax.value);
+
+ // adjust!
+ cl_updatescreen_quality += adjust;
+ cl_updatescreen_quality = bound(max(0.01, cl_minfps_qualitymin.value), cl_updatescreen_quality, cl_minfps_qualitymax.value);
+ }
+ else
+ {
+ cl_updatescreen_quality = 1;
+ r_refdef.lastdrawscreentime = 0;
+ }
+ }
+
+ drawscreenstart = Sys_DirtyTime();
+
Sbar_ShowFPS_Update();
if (!scr_initialized || !con_initialized || !scr_refresh.integer)
return;
}
- rendertime1 = Sys_DirtyTime();
-
conwidth = bound(160, vid_conwidth.value, 32768);
conheight = bound(90, vid_conheight.value, 24576);
if (vid_conwidth.value != conwidth)
R_ClearScreen(false);
r_refdef.view.clear = false;
r_refdef.view.isoverlay = false;
- f = pow((float)cl_updatescreen_quality, cl_minfps_qualitypower.value) * cl_minfps_qualityscale.value;
- r_refdef.view.quality = bound(cl_minfps_qualitymin.value, f, cl_minfps_qualitymax.value);
+
+ // calculate r_refdef.view.quality
+ r_refdef.view.quality = cl_updatescreen_quality;
#ifndef USE_GLES2
if (qglPolygonStipple)
}
#endif
- if (r_viewscale_fpsscaling.integer)
- GL_Finish();
- drawscreenstart = Sys_DirtyTime();
#ifndef USE_GLES2
if (R_Stereo_Active())
{
else
#endif
SCR_DrawScreen();
- if (r_viewscale_fpsscaling.integer)
- GL_Finish();
- r_refdef.lastdrawscreentime = Sys_DirtyTime() - drawscreenstart;
SCR_CaptureVideo();
if (qglFlush)
qglFlush(); // FIXME: should we really be using qglFlush here?
- // quality adjustment according to render time
- cl_updatescreen_rendertime += ((Sys_DirtyTime() - rendertime1) - cl_updatescreen_rendertime) * bound(0, cl_minfps_fade.value, 1);
- if (cl_minfps.value > 0 && cl_updatescreen_rendertime > 0 && !cls.timedemo && (!cls.capturevideo.active || !cls.capturevideo.realtime))
- cl_updatescreen_quality = 1 / (cl_updatescreen_rendertime * cl_minfps.value);
- else
- cl_updatescreen_quality = 1;
-
if (!vid_activewindow)
VID_SetMouse(false, false, false);
else if (key_consoleactive)