]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_backend.c
added back brackets so that developer isn't forced to 100 on startup every time
[xonotic/darkplaces.git] / gl_backend.c
index 13efbd30c5f04aab2519645d2ee50fee948a5171..0b7121d7d573c9c6c085290b0d108863ed307308 100644 (file)
@@ -256,7 +256,7 @@ void gl_backend_init(void)
 
 void GL_SetupView_Orientation_Identity (void)
 {
-       Matrix4x4_CreateIdentity(&backend_viewmatrix);
+       backend_viewmatrix = identitymatrix;
        memset(&backend_modelmatrix, 0, sizeof(backend_modelmatrix));
 }
 
@@ -445,7 +445,7 @@ void GL_SetupTextureState(void)
                unit->combinergb = GL_MODULATE;
                unit->combinealpha = GL_MODULATE;
                unit->texmatrixenabled = false;
-               unit->matrix = r_identitymatrix;
+               unit->matrix = identitymatrix;
        }
 
        for (i = 0;i < backendimageunits;i++)
@@ -628,7 +628,7 @@ void GL_DepthTest(int state)
 {
        if (gl_state.depthtest != state)
        {
-               if (r_showtrispass)
+               if (r_showtrispass && r_showdisabledepthtest.integer)
                        return;
                gl_state.depthtest = state;
                if (gl_state.depthtest)
@@ -647,8 +647,6 @@ void GL_ColorMask(int r, int g, int b, int a)
        int state = r*8 + g*4 + b*2 + a*1;
        if (gl_state.colormask != state)
        {
-               if (r_showtrispass)
-                       return;
                gl_state.colormask = state;
                qglColorMask((GLboolean)r, (GLboolean)g, (GLboolean)b, (GLboolean)a);CHECKGLERROR
        }
@@ -674,9 +672,9 @@ void GL_ShowTrisColor(float cr, float cg, float cb, float ca)
 {
        if (!r_showtrispass)
                return;
-       r_showtrispass = false;
+       r_showtrispass = 0;
        GL_Color(cr * r_showtris.value, cg * r_showtris.value, cb * r_showtris.value, ca);
-       r_showtrispass = true;
+       r_showtrispass = 1;
 }
 
 
@@ -724,8 +722,10 @@ void GL_ScissorTest(int state)
 
 void GL_Clear(int mask)
 {
+       // in showtris rendering, don't clear the color buffer as that would hide
+       // the accumulated lines
        if (r_showtrispass)
-               return;
+               mask &= ~GL_COLOR_BUFFER_BIT;
        qglClear(mask);CHECKGLERROR
 }
 
@@ -1740,104 +1740,87 @@ int r_stereo_side;
 
 void SCR_DrawScreen (void)
 {
-       for (r_showtrispass = 0;r_showtrispass <= (r_showtris.value > 0);r_showtrispass++)
-       {
-               R_Mesh_Start();
+       R_Mesh_Start();
 
+       if (r_timereport_active)
                R_TimeReport("setup");
 
-               if (r_showtrispass)
+       if (cls.signon == SIGNONS)
+       {
+               float size;
+
+               size = scr_viewsize.value * (1.0 / 100.0);
+               size = min(size, 1);
+
+               if (r_stereo_sidebyside.integer)
                {
-                       rmeshstate_t m;
-                       r_showtrispass = 0;
-                       GL_BlendFunc(GL_ONE, GL_ONE);
-                       GL_DepthTest(GL_FALSE);
-                       GL_DepthMask(GL_FALSE);
-                       memset(&m, 0, sizeof(m));
-                       R_Mesh_State(&m);
-                       //qglEnable(GL_LINE_SMOOTH);
-                       GL_ShowTrisColor(0.2,0.2,0.2,1);
-                       r_showtrispass = 1;
+                       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;
+                       if (r_stereo_side)
+                               r_refdef.x += r_refdef.width * 1.5;
                }
-
-               if (cls.signon == SIGNONS)
+               else
                {
-                       float size;
+                       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;
+               }
 
-                       size = scr_viewsize.value * (1.0 / 100.0);
-                       size = min(size, 1);
+               // LordHavoc: viewzoom (zoom in for sniper rifles, etc)
+               // LordHavoc: this is designed to produce widescreen fov values
+               // when the screen is wider than 4/3 width/height aspect, to do
+               // this it simply assumes the requested fov is the vertical fov
+               // for a 4x3 display, if the ratio is not 4x3 this makes the fov
+               // higher/lower according to the ratio
+               r_refdef.frustum_y = tan(scr_fov.value * cl.viewzoom * M_PI / 360.0) * (3.0/4.0);
+               r_refdef.frustum_x = r_refdef.frustum_y * (float)r_refdef.width / (float)r_refdef.height / vid_pixelheight.value;
 
-                       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;
-                               if (r_stereo_side)
-                                       r_refdef.x += 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.frustum_x *= r_refdef.frustumscale_x;
+               r_refdef.frustum_y *= r_refdef.frustumscale_y;
+
+               if(!CL_VM_UpdateView())
+                       R_RenderView();
+               else
+                       SCR_DrawConsole();
+
+               if (scr_zoomwindow.integer)
+               {
+                       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.y = 0;
 
-                       // LordHavoc: viewzoom (zoom in for sniper rifles, etc)
-                       // LordHavoc: this is designed to produce widescreen fov values
-                       // when the screen is wider than 4/3 width/height aspect, to do
-                       // this it simply assumes the requested fov is the vertical fov
-                       // for a 4x3 display, if the ratio is not 4x3 this makes the fov
-                       // higher/lower according to the ratio
-                       r_refdef.frustum_y = tan(scr_fov.value * cl.viewzoom * M_PI / 360.0) * (3.0/4.0);
-                       r_refdef.frustum_x = r_refdef.frustum_y * (float)r_refdef.width / (float)r_refdef.height / vid_pixelheight.value;
+                       r_refdef.frustum_y = tan(scr_zoomwindow_fov.value * cl.viewzoom * M_PI / 360.0) * (3.0/4.0);
+                       r_refdef.frustum_x = r_refdef.frustum_y * vid_pixelheight.value * (float)r_refdef.width / (float)r_refdef.height;
 
                        r_refdef.frustum_x *= r_refdef.frustumscale_x;
                        r_refdef.frustum_y *= r_refdef.frustumscale_y;
 
                        if(!CL_VM_UpdateView())
                                R_RenderView();
-                       else
-                               SCR_DrawConsole();
-
-                       if (scr_zoomwindow.integer)
-                       {
-                               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.y = 0;
-
-                               r_refdef.frustum_y = tan(scr_zoomwindow_fov.value * cl.viewzoom * M_PI / 360.0) * (3.0/4.0);
-                               r_refdef.frustum_x = r_refdef.frustum_y * vid_pixelheight.value * (float)r_refdef.width / (float)r_refdef.height;
-
-                               r_refdef.frustum_x *= r_refdef.frustumscale_x;
-                               r_refdef.frustum_y *= r_refdef.frustumscale_y;
-
-                               if(!CL_VM_UpdateView())
-                                       R_RenderView();
-                       }
                }
+       }
 
-               if (!r_stereo_sidebyside.integer)
-               {
-                       r_refdef.width = vid.width;
-                       r_refdef.height = vid.height;
-                       r_refdef.x = 0;
-                       r_refdef.y = 0;
-               }
+       if (!r_stereo_sidebyside.integer)
+       {
+               r_refdef.width = vid.width;
+               r_refdef.height = vid.height;
+               r_refdef.x = 0;
+               r_refdef.y = 0;
+       }
 
-               // draw 2D stuff
-               R_DrawQueue();
+       // draw 2D stuff
+       R_DrawQueue();
 
-               R_Mesh_Finish();
+       R_Mesh_Finish();
 
+       if (r_timereport_active)
                R_TimeReport("meshfinish");
-       }
-       r_showtrispass = 0;
-       //qglDisable(GL_LINE_SMOOTH);
 }
 
 void SCR_UpdateLoadingScreen (void)
@@ -1862,7 +1845,7 @@ void SCR_UpdateLoadingScreen (void)
        R_Textures_Frame();
        GL_SetupView_Mode_Ortho(0, 0, vid_conwidth.integer, vid_conheight.integer, -10, 100);
        R_Mesh_Start();
-       R_Mesh_Matrix(&r_identitymatrix);
+       R_Mesh_Matrix(&identitymatrix);
        // draw the loading plaque
        pic = Draw_CachePic("gfx/loading", false);
        x = (vid_conwidth.integer - pic->width)/2;
@@ -1888,7 +1871,7 @@ void SCR_UpdateLoadingScreen (void)
        GL_LockArrays(0, 0);
        R_Mesh_Finish();
        // refresh
-       VID_Finish();
+       VID_Finish(false);
 }
 
 /*
@@ -1912,6 +1895,8 @@ void SCR_UpdateScreen (void)
        if (gl_combine.integer && !gl_combine_extension)
                Cvar_SetValueQuick(&gl_combine, 0);
 
+       r_showtrispass = 0;
+
        CHECKGLERROR
        qglViewport(0, 0, vid.width, vid.height);
        qglDisable(GL_SCISSOR_TEST);
@@ -1921,7 +1906,8 @@ void SCR_UpdateScreen (void)
        qglClear(GL_COLOR_BUFFER_BIT);
        CHECKGLERROR
 
-       R_TimeReport("clear");
+       if (r_timereport_active)
+               R_TimeReport("clear");
 
        if (r_stereo_redblue.integer || r_stereo_redgreen.integer || r_stereo_redcyan.integer || r_stereo_sidebyside.integer)
        {
@@ -1961,27 +1947,11 @@ void SCR_UpdateScreen (void)
                r_refdef.viewentitymatrix = originalmatrix;
        }
        else
-       {
-               r_showtrispass = false;
                SCR_DrawScreen();
 
-               if (r_showtris.value > 0)
-               {
-                       rmeshstate_t m;
-                       GL_BlendFunc(GL_ONE, GL_ONE);
-                       GL_DepthTest(GL_FALSE);
-                       GL_DepthMask(GL_FALSE);
-                       memset(&m, 0, sizeof(m));
-                       R_Mesh_State(&m);
-                       r_showtrispass = true;
-                       GL_ShowTrisColor(0.2,0.2,0.2,1);
-                       SCR_DrawScreen();
-                       r_showtrispass = false;
-               }
-       }
-
-       VID_Finish();
-       R_TimeReport("finish");
+       VID_Finish(true);
+       if (r_timereport_active)
+               R_TimeReport("finish");
 }