]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_screen.c
removed trailing comments on cvar declarations and Cmd_AddCommand calls
[xonotic/darkplaces.git] / cl_screen.c
index e806e45a1ab3f01ebb25284ba061279408009f4c..60d14e39586cb76d6613db4aafd93fd1fcbb66db 100644 (file)
@@ -11,7 +11,7 @@
 #include "snd_main.h"
 
 cvar_t scr_viewsize = {CVAR_SAVE, "viewsize","100", "how large the view should be, 110 disables inventory bar, 120 disables status bar"};
-cvar_t scr_fov = {CVAR_SAVE, "fov","90", "field of vision, 1-170 degrees, default 90, some players use 110-130"};      // 1 - 170
+cvar_t scr_fov = {CVAR_SAVE, "fov","90", "field of vision, 1-170 degrees, default 90, some players use 110-130"};
 cvar_t scr_conalpha = {CVAR_SAVE, "scr_conalpha", "1", "opacity of console background"};
 cvar_t scr_conbrightness = {CVAR_SAVE, "scr_conbrightness", "1", "brightness of console background (0 = black, 1 = image)"};
 cvar_t scr_conforcewhiledisconnected = {0, "scr_conforcewhiledisconnected", "1", "forces fullscreen console while disconnected"};
@@ -44,6 +44,7 @@ cvar_t scr_zoomwindow_viewsizex = {CVAR_SAVE, "scr_zoomwindow_viewsizex", "20",
 cvar_t scr_zoomwindow_viewsizey = {CVAR_SAVE, "scr_zoomwindow_viewsizey", "20", "vertical viewsize of zoom window"};
 cvar_t scr_zoomwindow_fov = {CVAR_SAVE, "scr_zoomwindow_fov", "20", "fov of zoom window"};
 cvar_t scr_stipple = {0, "scr_stipple", "0", "interlacing-like stippling of the display"};
+cvar_t scr_refresh = {0, "scr_refresh", "1", "allows you to completely shut off rendering for benchmarking purposes"};
 
 
 int jpeg_supported = false;
@@ -316,8 +317,22 @@ static int SCR_DrawQWDownload(int offset)
        float size = 8;
        char temp[256];
        if (!cls.qw_downloadname[0])
+       {
+               cls.qw_downloadspeedrate = 0;
+               cls.qw_downloadspeedtime = realtime;
+               cls.qw_downloadspeedcount = 0;
                return 0;
-       dpsnprintf(temp, sizeof(temp), "Downloading %s ...  %3i%%\n", cls.qw_downloadname, cls.qw_downloadpercent);
+       }
+       if (realtime >= cls.qw_downloadspeedtime + 1)
+       {
+               cls.qw_downloadspeedrate = cls.qw_downloadspeedcount;
+               cls.qw_downloadspeedtime = realtime;
+               cls.qw_downloadspeedcount = 0;
+       }
+       if (cls.protocol == PROTOCOL_QUAKEWORLD)
+               dpsnprintf(temp, sizeof(temp), "Downloading %s %3i%% (%i) at %i bytes/s\n", cls.qw_downloadname, cls.qw_downloadpercent, cls.qw_downloadmemorycursize, cls.qw_downloadspeedrate);
+       else
+               dpsnprintf(temp, sizeof(temp), "Downloading %s %3i%% (%i/%i) at %i bytes/s\n", cls.qw_downloadname, cls.qw_downloadpercent, cls.qw_downloadmemorycursize, cls.qw_downloadmemorymaxsize, cls.qw_downloadspeedrate);
        len = (int)strlen(temp);
        x = (vid_conwidth.integer - len*size) / 2;
        y = vid_conheight.integer - size - offset;
@@ -461,7 +476,7 @@ void SCR_BeginLoadingPlaque (void)
 
        Host_StartVideo();
        S_StopAllSounds();
-       SCR_UpdateLoadingScreen();
+       SCR_UpdateLoadingScreen(false);
 }
 
 //=============================================================================
@@ -499,6 +514,7 @@ void R_TimeReport(char *desc)
 void R_TimeReport_Frame(void)
 {
        int i, j, lines, y;
+       cl_locnode_t *loc;
 
        if (r_speeds_string[0])
        {
@@ -536,6 +552,11 @@ void R_TimeReport_Frame(void)
                speedstringcount = 0;
                r_speeds_string[0] = 0;
                r_timereport_active = false;
+               // put the location name in the r_speeds display as it greatly helps
+               // when creating loc files
+               loc = CL_Locs_FindNearest(cl.movement_origin);
+               if (loc)
+                       sprintf(r_speeds_string + strlen(r_speeds_string), "Location: %s\n", loc->name);
                sprintf(r_speeds_string + strlen(r_speeds_string), "org:'%+8.2f %+8.2f %+8.2f' dir:'%+2.3f %+2.3f %+2.3f'\n", r_view.origin[0], r_view.origin[1], r_view.origin[2], r_view.forward[0], r_view.forward[1], r_view.forward[2]);
                sprintf(r_speeds_string + strlen(r_speeds_string), "%5i entities%6i surfaces%6i triangles%5i leafs%5i portals%6i particles\n", r_refdef.stats.entities, r_refdef.stats.entities_surfaces, r_refdef.stats.entities_triangles, r_refdef.stats.world_leafs, r_refdef.stats.world_portals, r_refdef.stats.particles);
                sprintf(r_speeds_string + strlen(r_speeds_string), "%4i lights%4i clears%4i scissored%7i light%7i shadow%7i dynamic\n", r_refdef.stats.lights, r_refdef.stats.lights_clears, r_refdef.stats.lights_scissored, r_refdef.stats.lights_lighttriangles, r_refdef.stats.lights_shadowtriangles, r_refdef.stats.lights_dynamicshadowtriangles);
@@ -614,6 +635,7 @@ void CL_Screen_Init(void)
        Cvar_RegisterVariable(&scr_zoomwindow_viewsizey);
        Cvar_RegisterVariable(&scr_zoomwindow_fov);
        Cvar_RegisterVariable(&scr_stipple);
+       Cvar_RegisterVariable(&scr_refresh);
 
        Cmd_AddCommand ("sizeup",SCR_SizeUp_f, "increase view size (increases viewsize cvar)");
        Cmd_AddCommand ("sizedown",SCR_SizeDown_f, "decrease view size (decreases viewsize cvar)");
@@ -812,11 +834,9 @@ static void SCR_CaptureVideo_RIFF_OverflowCheck(int framesize)
        cursize = SCR_CaptureVideo_RIFF_GetPosition() - cls.capturevideo.riffstackstartoffset[0];
        // if this would overflow the windows limit of 1GB per RIFF chunk, we need
        // to close the current RIFF chunk and open another for future frames
-       if (8 + cursize + framesize > 1<<30)
+       if (8 + cursize + framesize + cls.capturevideo.riffindexbuffer.cursize + 8 > 1<<30)
        {
                SCR_CaptureVideo_RIFF_Finish();
-               while (cls.capturevideo.riffstacklevel > 0)
-                       SCR_CaptureVideo_RIFF_Pop();
                // begin a new 1GB extended section of the AVI
                SCR_CaptureVideo_RIFF_Push("RIFF", "AVIX");
                SCR_CaptureVideo_RIFF_Push("LIST", "movi");
@@ -1523,8 +1543,6 @@ void SCR_DrawScreen (void)
 
                if(!CL_VM_UpdateView())
                        R_RenderView();
-               else
-                       SCR_DrawConsole();
 
                if (scr_zoomwindow.integer)
                {
@@ -1560,9 +1578,6 @@ void SCR_DrawScreen (void)
 
        // draw 2D stuff
 
-       //FIXME: force menu if nothing else to look at?
-       //if (key_dest == key_game && cls.signon != SIGNONS && cls.state == ca_disconnected)
-
        if (cls.signon == SIGNONS)
        {
                SCR_DrawNet ();
@@ -1577,8 +1592,7 @@ void SCR_DrawScreen (void)
        CL_DrawVideo();
        R_Shadow_EditLights_DrawSelectedLightProperties();
 
-       if(!csqc_loaded)
-               SCR_DrawConsole();
+       SCR_DrawConsole();
 
        SCR_DrawBrand();
 
@@ -1600,22 +1614,26 @@ void SCR_DrawScreen (void)
                R_TimeReport("meshfinish");
 }
 
-void SCR_UpdateLoadingScreen (void)
+void SCR_UpdateLoadingScreen (qboolean clear)
 {
        float x, y;
        cachepic_t *pic;
        float vertex3f[12];
        float texcoord2f[8];
        // don't do anything if not initialized yet
-       if (vid_hidden)
+       if (vid_hidden || !scr_refresh.integer)
                return;
        CHECKGLERROR
        qglViewport(0, 0, vid.width, vid.height);CHECKGLERROR
        //qglDisable(GL_SCISSOR_TEST);CHECKGLERROR
        //qglDepthMask(1);CHECKGLERROR
        qglColorMask(1,1,1,1);CHECKGLERROR
-       //qglClearColor(0,0,0,0);CHECKGLERROR
-       //qglClear(GL_COLOR_BUFFER_BIT);CHECKGLERROR
+       qglClearColor(0,0,0,0);CHECKGLERROR
+       // when starting up a new video mode, make sure the screen is cleared to black
+       if (clear)
+       {
+               qglClear(GL_COLOR_BUFFER_BIT);CHECKGLERROR
+       }
        //qglDisable(GL_CULL_FACE);CHECKGLERROR
        //R_ClearScreen();
        R_Textures_Frame();
@@ -1645,29 +1663,30 @@ void SCR_UpdateLoadingScreen (void)
        texcoord2f[6] = 0;texcoord2f[7] = 1;
        if (vid.stereobuffer)
        {
-               qglDrawBuffer(GL_BACK_LEFT);
+               qglDrawBuffer(GL_FRONT_LEFT);
                R_Mesh_Draw(0, 4, 2, polygonelements);
-               qglDrawBuffer(GL_BACK_RIGHT);
+               qglDrawBuffer(GL_FRONT_RIGHT);
                R_Mesh_Draw(0, 4, 2, polygonelements);
        }
        else
        {
-               qglDrawBuffer(GL_BACK);
+               qglDrawBuffer(GL_FRONT);
                R_Mesh_Draw(0, 4, 2, polygonelements);
        }
        R_Mesh_Finish();
        // refresh
-       VID_Finish(false);
+       // not necessary when rendering to GL_FRONT buffers
+       //VID_Finish(false);
 }
 
 void CL_UpdateScreen(void)
 {
        float conwidth, conheight;
 
-       if (vid_hidden)
+       if (vid_hidden || !scr_refresh.integer)
                return;
 
-       if (!scr_initialized || !con_initialized || vid_hidden)
+       if (!scr_initialized || !con_initialized)
                return;                         // not initialized yet
 
        // don't allow cheats in multiplayer