]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_screen.c
significant surface renderer optimizations
[xonotic/darkplaces.git] / cl_screen.c
index d8f34cc215011eef5858a374aafc40aad852c592..4f5c56faf9ddc8e6f9d6e1b2a91ed5dce51d78e2 100644 (file)
@@ -8,11 +8,10 @@
 
 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_conspeed = {CVAR_SAVE, "scr_conspeed","900", "speed of console open/close"}; // LordHavoc: quake used 300
 cvar_t scr_conalpha = {CVAR_SAVE, "scr_conalpha", "1", "opacity of console background"};
-cvar_t scr_conbrightness = {CVAR_SAVE, "scr_conbrightness", "0.2", "brightness of console background (0 = black, 1 = image)"};
+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"};
-cvar_t scr_menuforcewhiledisconnected = {0, "scr_menuforcewhiledisconnected", "1", "forces menu while disconnected"};
+cvar_t scr_menuforcewhiledisconnected = {0, "scr_menuforcewhiledisconnected", "0", "forces menu while disconnected"};
 cvar_t scr_centertime = {0, "scr_centertime","2", "how long centerprint messages show"};
 cvar_t scr_showram = {CVAR_SAVE, "showram","1", "show ram icon if low on surface cache memory (not used)"};
 cvar_t scr_showturtle = {CVAR_SAVE, "showturtle","0", "show turtle icon when framerate is too low (not used)"};
@@ -108,7 +107,7 @@ void SCR_DrawCenterString (void)
 
 // the finale prints the characters one at a time
        if (cl.intermission)
-               remaining = scr_printspeed.value * (cl.time - scr_centertime_start);
+               remaining = (int)(scr_printspeed.value * (cl.time - scr_centertime_start));
        else
                remaining = 9999;
 
@@ -119,7 +118,7 @@ void SCR_DrawCenterString (void)
                return;
 
        if (scr_center_lines <= 4)
-               y = vid_conheight.integer*0.35;
+               y = (int)(vid_conheight.integer*0.35);
        else
                y = 48;
 
@@ -157,7 +156,7 @@ void SCR_CheckDrawCenterString (void)
        if (scr_center_lines > scr_erase_lines)
                scr_erase_lines = scr_center_lines;
 
-       scr_centertime_off -= host_frametime;
+       scr_centertime_off -= cl.realframetime;
 
        // don't draw if this is a normal stats-screen intermission,
        // only if it is not an intermission, or a finale intermission
@@ -186,7 +185,7 @@ void SCR_DrawTurtle (void)
        if (!scr_showturtle.integer)
                return;
 
-       if (host_frametime < 0.1)
+       if (cl.realframetime < 0.1)
        {
                count = 0;
                return;
@@ -196,7 +195,7 @@ void SCR_DrawTurtle (void)
        if (count < 3)
                return;
 
-       DrawQ_Pic (0, 0, Draw_CachePic("gfx/turtle", false), 0, 0, 1, 1, 1, 1, 0);
+       DrawQ_Pic (0, 0, Draw_CachePic("gfx/turtle", true), 0, 0, 1, 1, 1, 1, 0);
 }
 
 /*
@@ -213,7 +212,7 @@ void SCR_DrawNet (void)
        if (cls.demoplayback)
                return;
 
-       DrawQ_Pic (64, 0, Draw_CachePic("gfx/net", false), 0, 0, 1, 1, 1, 1, 0);
+       DrawQ_Pic (64, 0, Draw_CachePic("gfx/net", true), 0, 0, 1, 1, 1, 1, 0);
 }
 
 /*
@@ -352,24 +351,7 @@ void SCR_SetUpToDrawConsole (void)
        else
                conlines = 0;                           // none visible
 
-       if (scr_conspeed.value)
-       {
-               if (scr_con_current > conlines)
-               {
-                       scr_con_current -= scr_conspeed.value*host_realframetime;
-                       if (scr_con_current < conlines)
-                               scr_con_current = conlines;
-
-               }
-               else if (scr_con_current < conlines)
-               {
-                       scr_con_current += scr_conspeed.value*host_realframetime;
-                       if (scr_con_current > conlines)
-                               scr_con_current = conlines;
-               }
-       }
-       else
-               scr_con_current = conlines;
+       scr_con_current = conlines;
 }
 
 /*
@@ -385,7 +367,7 @@ void SCR_DrawConsole (void)
                Con_DrawConsole (vid_conheight.integer);
        }
        else if (scr_con_current)
-               Con_DrawConsole (scr_con_current);
+               Con_DrawConsole ((int)scr_con_current);
        else
        {
                con_vislines = 0;
@@ -422,7 +404,7 @@ void R_TimeReport(char *desc)
        int length;
        int t;
 
-       if (r_speeds.integer < 2 || !r_timereport_active || r_showtrispass)
+       if (r_speeds.integer < 2 || !r_timereport_active)
                return;
 
        qglFinish();
@@ -528,7 +510,6 @@ void CL_Screen_Init(void)
 {
        Cvar_RegisterVariable (&scr_fov);
        Cvar_RegisterVariable (&scr_viewsize);
-       Cvar_RegisterVariable (&scr_conspeed);
        Cvar_RegisterVariable (&scr_conalpha);
        Cvar_RegisterVariable (&scr_conbrightness);
        Cvar_RegisterVariable (&scr_conforcewhiledisconnected);
@@ -891,7 +872,7 @@ void SCR_CaptureVideo(void)
                if (cls.capturevideo_soundfile)
                {
                        // preserve sound sync by duplicating frames when running slow
-                       newframenum = (Sys_DoubleTime() - cls.capturevideo_starttime) * cls.capturevideo_framerate;
+                       newframenum = (int)((Sys_DoubleTime() - cls.capturevideo_starttime) * cls.capturevideo_framerate);
                }
                else
                        newframenum = cls.capturevideo_frame + 1;
@@ -1077,7 +1058,7 @@ void SHOWLMP_drawall(void)
        int i;
        for (i = 0;i < SHOWLMP_MAXLABELS;i++)
                if (showlmp[i].isactive)
-                       DrawQ_Pic(showlmp[i].x, showlmp[i].y, Draw_CachePic(showlmp[i].pic, false), 0, 0, 1, 1, 1, 1, 0);
+                       DrawQ_Pic(showlmp[i].x, showlmp[i].y, Draw_CachePic(showlmp[i].pic, true), 0, 0, 1, 1, 1, 1, 0);
 }
 
 void SHOWLMP_clear(void)
@@ -1183,19 +1164,19 @@ void SCR_DrawScreen (void)
 
                if (r_stereo_sidebyside.integer)
                {
-                       r_refdef.width = vid.width * size / 2.5;
-                       r_refdef.height = vid.height * size / 2.5 * (1 - bound(0, r_letterbox.value, 100) / 100);
-                       r_refdef.x = (vid.width - r_refdef.width * 2.5) * 0.5;
-                       r_refdef.y = (vid.height - r_refdef.height)/2;
+                       r_refdef.width = (int)(vid.width * size / 2.5);
+                       r_refdef.height = (int)(vid.height * size / 2.5 * (1 - bound(0, r_letterbox.value, 100) / 100));
+                       r_refdef.x = (int)((vid.width - r_refdef.width * 2.5) * 0.5);
+                       r_refdef.y = (int)((vid.height - r_refdef.height)/2);
                        if (r_stereo_side)
-                               r_refdef.x += r_refdef.width * 1.5;
+                               r_refdef.x += (int)(r_refdef.width * 1.5);
                }
                else
                {
-                       r_refdef.width = vid.width * size;
-                       r_refdef.height = vid.height * size * (1 - bound(0, r_letterbox.value, 100) / 100);
-                       r_refdef.x = (vid.width - r_refdef.width)/2;
-                       r_refdef.y = (vid.height - r_refdef.height)/2;
+                       r_refdef.width = (int)(vid.width * size);
+                       r_refdef.height = (int)(vid.height * size * (1 - bound(0, r_letterbox.value, 100) / 100));
+                       r_refdef.x = (int)((vid.width - r_refdef.width)/2);
+                       r_refdef.y = (int)((vid.height - r_refdef.height)/2);
                }
 
                // LordHavoc: viewzoom (zoom in for sniper rifles, etc)
@@ -1219,9 +1200,9 @@ void SCR_DrawScreen (void)
                {
                        float sizex = bound(10, scr_zoomwindow_viewsizex.value, 100) / 100.0;
                        float sizey = bound(10, scr_zoomwindow_viewsizey.value, 100) / 100.0;
-                       r_refdef.width = vid.width * sizex;
-                       r_refdef.height = vid.height * sizey;
-                       r_refdef.x = (vid.width - r_refdef.width)/2;
+                       r_refdef.width = (int)(vid.width * sizex);
+                       r_refdef.height = (int)(vid.height * sizey);
+                       r_refdef.x = (int)((vid.width - r_refdef.width)/2);
                        r_refdef.y = 0;
 
                        r_refdef.frustum_y = tan(scr_zoomwindow_fov.value * cl.viewzoom * M_PI / 360.0) * (3.0/4.0);
@@ -1290,12 +1271,11 @@ void SCR_UpdateLoadingScreen (void)
 {
        float x, y;
        cachepic_t *pic;
-       rmeshstate_t m;
+       float vertex3f[12];
+       float texcoord2f[8];
        // don't do anything if not initialized yet
        if (vid_hidden)
                return;
-       r_showtrispass = 0;
-       VID_UpdateGamma(false);
        qglViewport(0, 0, vid.width, vid.height);
        //qglDisable(GL_SCISSOR_TEST);
        //qglDepthMask(1);
@@ -1310,25 +1290,26 @@ void SCR_UpdateLoadingScreen (void)
        R_Mesh_Start();
        R_Mesh_Matrix(&identitymatrix);
        // draw the loading plaque
-       pic = Draw_CachePic("gfx/loading", false);
+       pic = Draw_CachePic("gfx/loading", true);
        x = (vid_conwidth.integer - pic->width)/2;
        y = (vid_conheight.integer - pic->height)/2;
        GL_Color(1,1,1,1);
        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        GL_DepthTest(false);
-       memset(&m, 0, sizeof(m));
-       m.pointer_vertex = varray_vertex3f;
-       m.pointer_texcoord[0] = varray_texcoord2f[0];
-       m.tex[0] = R_GetTexture(pic->tex);
-       R_Mesh_State(&m);
-       varray_vertex3f[0] = varray_vertex3f[9] = x;
-       varray_vertex3f[1] = varray_vertex3f[4] = y;
-       varray_vertex3f[3] = varray_vertex3f[6] = x + pic->width;
-       varray_vertex3f[7] = varray_vertex3f[10] = y + pic->height;
-       varray_texcoord2f[0][0] = 0;varray_texcoord2f[0][1] = 0;
-       varray_texcoord2f[0][2] = 1;varray_texcoord2f[0][3] = 0;
-       varray_texcoord2f[0][4] = 1;varray_texcoord2f[0][5] = 1;
-       varray_texcoord2f[0][6] = 0;varray_texcoord2f[0][7] = 1;
+       R_Mesh_VertexPointer(vertex3f);
+       R_Mesh_ColorPointer(NULL);
+       R_Mesh_ResetTextureState();
+       R_Mesh_TexBind(0, R_GetTexture(pic->tex));
+       R_Mesh_TexCoordPointer(0, 2, texcoord2f);
+       vertex3f[2] = vertex3f[5] = vertex3f[8] = vertex3f[11] = 0;
+       vertex3f[0] = vertex3f[9] = x;
+       vertex3f[1] = vertex3f[4] = y;
+       vertex3f[3] = vertex3f[6] = x + pic->width;
+       vertex3f[7] = vertex3f[10] = y + pic->height;
+       texcoord2f[0] = 0;texcoord2f[1] = 0;
+       texcoord2f[2] = 1;texcoord2f[3] = 0;
+       texcoord2f[4] = 1;texcoord2f[5] = 1;
+       texcoord2f[6] = 0;texcoord2f[7] = 1;
        R_Mesh_Draw(0, 4, 2, polygonelements);
        R_Mesh_Finish();
        // refresh
@@ -1403,15 +1384,11 @@ void CL_UpdateScreen(void)
        if (r_timereport_active)
                R_TimeReport("other");
 
-       VID_UpdateGamma(false);
-
        SCR_SetUpToDrawConsole();
 
        if (r_timereport_active)
                R_TimeReport("start");
 
-       r_showtrispass = 0;
-
        CHECKGLERROR
        qglViewport(0, 0, vid.width, vid.height);
        qglDisable(GL_SCISSOR_TEST);