]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
added r_renderview cvar (similar to scr_refresh but disables only 3D
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 3 Oct 2009 22:47:13 +0000 (22:47 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 3 Oct 2009 22:47:13 +0000 (22:47 +0000)
renders)
reworked scr_refresh and r_render cvars to only disable certain
rendering operations
changed where Sbar_ShowFPS code is called so that it appears even if
r_letterbox is on, and updates even while scr_refresh is 0

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9291 d7cf8633-e32d-0410-b094-e92efae38249

cl_screen.c
gl_backend.c
gl_rmain.c
render.h
sbar.c
vid_agl.c
vid_glx.c
vid_sdl.c
vid_wgl.c

index 65f3707e589bea1a59885b14b66ea85adbcdbaa3..e7a6e2af824048a18af2334408de2ba514a44ad4 100644 (file)
@@ -728,6 +728,14 @@ void R_TimeReport_BeginFrame(void)
        }
 }
 
+static int R_CountLeafTriangles(const dp_model_t *model, const mleaf_t *leaf)
+{
+       int i, triangles = 0;
+       for (i = 0;i < leaf->numleafsurfaces;i++)
+               triangles += model->data_surfaces[leaf->firstleafsurface[i]].num_triangles;
+       return triangles;
+}
+
 void R_TimeReport_EndFrame(void)
 {
        int i, j, lines, y;
@@ -745,17 +753,19 @@ void R_TimeReport_EndFrame(void)
                dpsnprintf(string, sizeof(string),
 "%s%s\n"
 "%3i renders org:'%+8.2f %+8.2f %+8.2f' dir:'%+2.3f %+2.3f %+2.3f'\n"
+"%5i viewleaf%5i cluster%2i area%4i brushes%4i surfaces(%7i triangles)\n"
 "%7i surfaces%7i triangles %5i entities (%7i surfaces%7i triangles)\n"
 "%5i leafs%5i portals%6i/%6i particles%6i/%6i decals %3i%% quality\n"
-"%7i lightmap updates (%7i pixels)%s\n"
+"%7i lightmap updates (%7i pixels)\n"
 "%4i lights%4i clears%4i scissored%7i light%7i shadow%7i dynamic\n"
 "rendered%6i meshes%8i triangles bloompixels%8i copied%8i drawn\n"
 "%s"
 , loc ? "Location: " : "", loc ? loc->name : ""
 , r_refdef.stats.renders, r_refdef.view.origin[0], r_refdef.view.origin[1], r_refdef.view.origin[2], r_refdef.view.forward[0], r_refdef.view.forward[1], r_refdef.view.forward[2]
+, viewleaf ? (int)(viewleaf - r_refdef.scene.worldmodel->brush.data_leafs) : -1, viewleaf ? viewleaf->clusterindex : -1, viewleaf ? viewleaf->areaindex : -1, viewleaf ? viewleaf->numleafbrushes : 0, viewleaf ? viewleaf->numleafsurfaces : 0, viewleaf ? R_CountLeafTriangles(r_refdef.scene.worldmodel, viewleaf) : 0
 , r_refdef.stats.world_surfaces, r_refdef.stats.world_triangles, 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, cl.num_particles, r_refdef.stats.decals, cl.num_decals, (int)(100 * r_refdef.view.quality)
-, r_refdef.stats.lightmapupdates, r_refdef.stats.lightmapupdatepixels, viewleaf ? va(" clusterindex%6i", viewleaf->clusterindex) : ""
+, r_refdef.stats.lightmapupdates, r_refdef.stats.lightmapupdatepixels
 , 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
 , r_refdef.stats.meshes, r_refdef.stats.meshes_elements / 3, r_refdef.stats.bloom_copypixels, r_refdef.stats.bloom_drawpixels
 , r_speeds_timestring);
@@ -1186,7 +1196,7 @@ void SCR_CaptureVideo_SoundFrame(const portable_sampleframe_t *paintbuffer, size
 void SCR_CaptureVideo(void)
 {
        int newframenum;
-       if (cl_capturevideo.integer && r_render.integer)
+       if (cl_capturevideo.integer)
        {
                if (!cls.capturevideo.active)
                        SCR_CaptureVideo_BeginVideo();
@@ -1401,9 +1411,6 @@ qboolean SCR_ScreenShot(char *filename, unsigned char *buffer1, unsigned char *b
        int     indices[3] = {0,1,2};
        qboolean ret;
 
-       if (!r_render.integer)
-               return false;
-
        CHECKGLERROR
        qglReadPixels (x, y, width, height, jpeg ? GL_RGB : GL_BGR, GL_UNSIGNED_BYTE, buffer1);CHECKGLERROR
 
@@ -1471,8 +1478,7 @@ void R_ClearScreen(qboolean fogcolor)
                qglClearStencil(128);CHECKGLERROR
        }
        // clear the screen
-       if (r_render.integer)
-               GL_Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | (gl_stencil ? GL_STENCIL_BUFFER_BIT : 0));
+       GL_Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | (gl_stencil ? GL_STENCIL_BUFFER_BIT : 0));
        // set dithering mode
        if (gl_dither.integer)
        {
@@ -1490,6 +1496,7 @@ void R_Shadow_EditLights_DrawSelectedLightProperties(void);
 
 int r_stereo_side;
 
+extern void Sbar_ShowFPS(void);
 void SCR_DrawScreen (void)
 {
        R_Mesh_Start();
@@ -1592,6 +1599,7 @@ void SCR_DrawScreen (void)
                SCR_DrawPause ();
                if (!r_letterbox.value)
                        Sbar_Draw();
+               Sbar_ShowFPS();
                SHOWLMP_drawall();
                SCR_CheckDrawCenterString();
        }
@@ -1892,7 +1900,7 @@ void SCR_UpdateLoadingScreen (qboolean clear)
        int                     old_key_consoleactive;
 
        // don't do anything if not initialized yet
-       if (vid_hidden || !scr_refresh.integer || cls.state == ca_dedicated)
+       if (vid_hidden || cls.state == ca_dedicated)
                return;
        
        if(loadingscreentime == realtime)
@@ -1953,13 +1961,16 @@ extern cvar_t cl_minfps_qualitypower;
 extern cvar_t cl_minfps_qualityscale;
 static double cl_updatescreen_rendertime = 0;
 static double cl_updatescreen_quality = 1;
+extern void Sbar_ShowFPS_Update(void);
 void CL_UpdateScreen(void)
 {
        double rendertime1;
        float conwidth, conheight;
        float f;
 
-       if (!scr_initialized || !con_initialized)
+       Sbar_ShowFPS_Update();
+
+       if (!scr_initialized || !con_initialized || !scr_refresh.integer)
                return;                         // not initialized yet
 
        if(gamemode == GAME_NEXUIZ)
@@ -1975,7 +1986,7 @@ void CL_UpdateScreen(void)
                memcpy(palette_rgb_shirtscoreboard[15], palette_rgb_shirtcolormap[15], sizeof(*palette_rgb_shirtcolormap));
        }
 
-       if (vid_hidden || !scr_refresh.integer)
+       if (vid_hidden)
                return;
 
        rendertime1 = Sys_DoubleTime();
index e4dc975586631741c790c9fafc1c4b1fc5725ff3..35a0e01fa12b4b12f6c71de92f66df596af3543e 100644 (file)
@@ -9,7 +9,8 @@ cvar_t gl_mesh_prefer_short_elements = {0, "gl_mesh_prefer_short_elements", "1",
 cvar_t gl_paranoid = {0, "gl_paranoid", "0", "enables OpenGL error checking and other tests"};
 cvar_t gl_printcheckerror = {0, "gl_printcheckerror", "0", "prints all OpenGL error checks, useful to identify location of driver crashes"};
 
-cvar_t r_render = {0, "r_render", "1", "enables rendering calls (you want this on!)"};
+cvar_t r_render = {0, "r_render", "1", "enables rendering 3D views (you want this on!)"};
+cvar_t r_renderview = {0, "r_renderview", "1", "enables rendering 3D views (you want this on!)"};
 cvar_t r_waterwarp = {CVAR_SAVE, "r_waterwarp", "1", "warp view while underwater"};
 cvar_t gl_polyblend = {CVAR_SAVE, "gl_polyblend", "1", "tints view while underwater, hurt, etc"};
 cvar_t gl_dither = {CVAR_SAVE, "gl_dither", "1", "enables OpenGL dithering (16bit looks bad with this off)"};
@@ -251,6 +252,7 @@ void gl_backend_init(void)
        }
 
        Cvar_RegisterVariable(&r_render);
+       Cvar_RegisterVariable(&r_renderview);
        Cvar_RegisterVariable(&r_waterwarp);
        Cvar_RegisterVariable(&gl_polyblend);
        Cvar_RegisterVariable(&v_flipped);
@@ -260,9 +262,6 @@ void gl_backend_init(void)
        Cvar_RegisterVariable(&gl_vbo);
        Cvar_RegisterVariable(&gl_paranoid);
        Cvar_RegisterVariable(&gl_printcheckerror);
-#ifdef NORENDER
-       Cvar_SetValue("r_render", 0);
-#endif
 
        Cvar_RegisterVariable(&gl_mesh_drawrangeelements);
        Cvar_RegisterVariable(&gl_mesh_testarrayelement);
@@ -1044,7 +1043,7 @@ void GL_LockArrays(int first, int count)
                        qglUnlockArraysEXT();
                        CHECKGLERROR
                }
-               if (count && gl_supportslockarrays && gl_lockarrays.integer && r_render.integer)
+               if (count && gl_supportslockarrays && gl_lockarrays.integer)
                {
                        gl_state.lockrange_first = first;
                        gl_state.lockrange_count = count;
@@ -1291,7 +1290,7 @@ void R_Mesh_Draw(int firstvertex, int numvertices, int firsttriangle, int numtri
                }
                CHECKGLERROR
        }
-       if (r_render.integer)
+       if (r_render.integer || r_refdef.draw2dstage)
        {
                CHECKGLERROR
                if (gl_mesh_testmanualfeeding.integer)
index 6778507e0330725f27fb74161d55f2200b5e1620..f11963bd0ee269a232e8ed028fe771c9cd28c23f 100644 (file)
@@ -4600,7 +4600,7 @@ void R_RenderView(void)
                return;
        }
 
-       if (!r_refdef.scene.entities || r_refdef.view.width * r_refdef.view.height == 0/* || !r_refdef.scene.worldmodel*/)
+       if (!r_refdef.scene.entities || r_refdef.view.width * r_refdef.view.height == 0 || !r_renderview.integer/* || !r_refdef.scene.worldmodel*/)
                return; //Host_Error ("R_RenderView: NULL worldmodel");
 
        r_refdef.view.colorscale = r_hdr_scenebrightness.value;
index af979e901364f946dc61c35e043b16d1243d2b65..66128bb58d47e133d51583053816235d889605d5 100644 (file)
--- a/render.h
+++ b/render.h
@@ -163,6 +163,7 @@ int R_CullBoxCustomPlanes(const vec3_t mins, const vec3_t maxs, int numplanes, c
 #include "r_lerpanim.h"
 
 extern cvar_t r_render;
+extern cvar_t r_renderview;
 extern cvar_t r_waterwarp;
 
 extern cvar_t r_textureunits;
diff --git a/sbar.c b/sbar.c
index c6fcbf648fc57eb4c0950bb10f2c498a8dde31d9..18f3b7ee891682f17daed95bb01e0136daf00f8f 100644 (file)
--- a/sbar.c
+++ b/sbar.c
@@ -1090,6 +1090,27 @@ static void get_showspeed_unit(int unitnumber, double *conversion_factor, const
        }
 }
 
+static double showfps_nexttime = 0, showfps_lasttime = -1;
+static double showfps_framerate = 0;
+static int showfps_framecount = 0;
+
+void Sbar_ShowFPS_Update(void)
+{
+       double interval = 1;
+       double newtime;
+       newtime = realtime;
+       if (newtime >= showfps_nexttime)
+       {
+               showfps_framerate = showfps_framecount / (newtime - showfps_lasttime);
+               if (showfps_nexttime < newtime - interval * 1.5)
+                       showfps_nexttime = newtime;
+               showfps_lasttime = newtime;
+               showfps_nexttime += interval;
+               showfps_framecount = 0;
+       }
+       showfps_framecount++;
+}
+
 void Sbar_ShowFPS(void)
 {
        float fps_x, fps_y, fps_scalex, fps_scaley, fps_height;
@@ -1110,32 +1131,13 @@ void Sbar_ShowFPS(void)
        topspeedstring[0] = 0;
        if (showfps.integer)
        {
-               float calc;
-               static double nexttime = 0, lasttime = 0;
-               static double framerate = 0;
-               static int framecount = 0;
-               double interval = 1;
-               double newtime;
-               newtime = Sys_DoubleTime();
-               if (newtime >= nexttime)
-               {
-                       framerate = framecount / (newtime - lasttime);
-                       if (nexttime < newtime - interval * 1.5)
-                               nexttime = newtime;
-                       lasttime = newtime;
-                       nexttime += interval;
-                       framecount = 0;
-               }
-               framecount++;
-               calc = framerate;
-               red = (calc < 1.0f);
-
+               red = (showfps_framerate < 1.0f);
                if(showfps.integer == 2)
-                       dpsnprintf(fpsstring, sizeof(fpsstring), "%7.3f mspf", (1000.0 / calc));
+                       dpsnprintf(fpsstring, sizeof(fpsstring), "%7.3f mspf", (1000.0 / showfps_framerate));
                else if (red)
-                       dpsnprintf(fpsstring, sizeof(fpsstring), "%4i spf", (int)(1.0 / calc + 0.5));
+                       dpsnprintf(fpsstring, sizeof(fpsstring), "%4i spf", (int)(1.0 / showfps_framerate + 0.5));
                else
-                       dpsnprintf(fpsstring, sizeof(fpsstring), "%4i fps", (int)(calc + 0.5));
+                       dpsnprintf(fpsstring, sizeof(fpsstring), "%4i fps", (int)(showfps_framerate + 0.5));
        }
        if (showtime.integer)
                strlcpy(timestring, Sys_TimeString(showtime_format.string), sizeof(timestring));
@@ -1717,8 +1719,6 @@ void Sbar_Draw (void)
                }
        }
 
-       Sbar_ShowFPS();
-
        if (cl.csqc_vidvars.drawcrosshair && crosshair.integer >= 1 && !cl.intermission && !r_letterbox.value)
        {
                pic = Draw_CachePic (va("gfx/crosshair%i", crosshair.integer));
index 8586ef07e7c8fdf7e71520133e41316e1ff5966c..c5c55fa2b710ffc72d34e009abe5a0acedbf1908 100644 (file)
--- a/vid_agl.c
+++ b/vid_agl.c
@@ -219,7 +219,7 @@ void VID_Finish (void)
                        Con_Printf("ERROR: can't %s vsync\n", vid_usevsync ? "activate" : "deactivate");
        }
 
-       if (r_render.integer)
+       if (!vid_hidden)
        {
                CHECKGLERROR
                if (r_speeds.integer == 2 || gl_finish.integer)
index 165dcc7919cfbba8dfacc5ad56bc359a9cbb483a..a0284127923696f38175a37734677dd9b2f744e8 100644 (file)
--- a/vid_glx.c
+++ b/vid_glx.c
@@ -697,7 +697,7 @@ void VID_Finish (void)
                        Con_Print("glXSwapIntervalSGI didn't accept the vid_vsync change, it will take effect on next vid_restart (GLX_SGI_swap_control does not allow turning off vsync)\n");
        }
 
-       if (r_render.integer)
+       if (!vid_hidden)
        {
                CHECKGLERROR
                if (r_speeds.integer == 2 || gl_finish.integer)
index 81d0fe269bbf30e9fb9ab75e6913624df5de175a..d18b5a42506c640b52b5c23275cfbd4c3b3c8a6c 100644 (file)
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -830,7 +830,7 @@ void VID_Finish (void)
 
        VID_UpdateGamma(false, 256);
 
-       if (r_render.integer && !vid_hidden)
+       if (!vid_hidden)
        {
                CHECKGLERROR
                if (r_speeds.integer == 2 || gl_finish.integer)
index 2b1e9da23b9de875574777319d2d3e66e14b22c2..4405533d6312422beed076fcccde81668b7a7d6e 100644 (file)
--- a/vid_wgl.c
+++ b/vid_wgl.c
@@ -257,7 +257,7 @@ void VID_Finish (void)
                qwglSwapIntervalEXT (vid_usevsync);
        }
 
-       if (r_render.integer && !vid_hidden)
+       if (!vid_hidden)
        {
                CHECKGLERROR
                if (r_speeds.integer == 2 || gl_finish.integer)