]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_rmain.c
eliminated calls to Matrix4x4_CreateIdentity (now copies from the already existing...
[xonotic/darkplaces.git] / gl_rmain.c
index fa278314082438e75724a5db86330a8b0f74f15a..e22cf40bb84a78f1a9b6e8a10a30b1a6b59c8dfd 100644 (file)
@@ -28,7 +28,7 @@ int r_framecount;
 
 mplane_t frustum[5];
 
-matrix4x4_t r_identitymatrix;
+matrix4x4_t identitymatrix;
 
 renderstats_t renderstats;
 
@@ -450,7 +450,6 @@ void gl_main_newmap(void)
 
 void GL_Main_Init(void)
 {
-       Matrix4x4_CreateIdentity(&r_identitymatrix);
 // FIXME: move this to client?
        FOG_registercvars();
        Cvar_RegisterVariable(&r_showtris);
@@ -482,7 +481,7 @@ void GL_Main_Init(void)
        Cvar_RegisterVariable(&developer_texturelogging);
        Cvar_RegisterVariable(&gl_lightmaps);
        Cvar_RegisterVariable(&r_test);
-       if (gamemode == GAME_NEHAHRA || gamemode == GAME_NEXUIZ || gamemode == GAME_TENEBRAE)
+       if (gamemode == GAME_NEHAHRA || gamemode == GAME_TENEBRAE)
                Cvar_SetValue("r_fullbrights", 0);
        R_RegisterModule("GL_Main", gl_main_start, gl_main_shutdown, gl_main_newmap);
 }
@@ -862,7 +861,7 @@ static void R_BlendView(void)
        GL_SetupView_Mode_Ortho(0, 0, 1, 1, -10, 100);
        GL_DepthMask(true);
        GL_DepthTest(false);
-       R_Mesh_Matrix(&r_identitymatrix);
+       R_Mesh_Matrix(&identitymatrix);
        // vertex coordinates for a quad that covers the screen exactly
        varray_vertex3f[0] = 0;varray_vertex3f[1] = 0;varray_vertex3f[2] = 0;
        varray_vertex3f[3] = 1;varray_vertex3f[4] = 0;varray_vertex3f[5] = 0;
@@ -1091,7 +1090,8 @@ void R_RenderView(void)
        R_ClearScreen();
        R_Textures_Frame();
        R_UpdateFog();
-       R_TimeReport("setup");
+       if (r_timereport_active)
+               R_TimeReport("setup");
 
        qglDepthFunc(GL_LEQUAL);
        qglPolygonOffset(0, 0);
@@ -1103,7 +1103,8 @@ void R_RenderView(void)
        qglDisable(GL_POLYGON_OFFSET_FILL);
 
        R_BlendView();
-       R_TimeReport("blendview");
+       if (r_timereport_active)
+               R_TimeReport("blendview");
 
        GL_Scissor(0, 0, vid.width, vid.height);
        GL_ScissorTest(false);
@@ -1137,7 +1138,8 @@ void CSQC_R_ClearScreen (void)
        R_ClearScreen();
        R_Textures_Frame();
        R_UpdateFog();
-       R_TimeReport("setup");
+       if (r_timereport_active)
+               R_TimeReport("setup");
 }
 
 //[515]: csqc
@@ -1153,7 +1155,8 @@ void CSQC_R_RenderScene (void)
        qglDisable(GL_POLYGON_OFFSET_FILL);
 
        R_BlendView();
-       R_TimeReport("blendview");
+       if (r_timereport_active)
+               R_TimeReport("blendview");
 
        GL_Scissor(0, 0, vid.width, vid.height);
        GL_ScissorTest(false);
@@ -1186,10 +1189,12 @@ void R_RenderScene(void)
        R_SkyStartFrame();
 
        R_WorldVisibility();
-       R_TimeReport("worldvis");
+       if (r_timereport_active)
+               R_TimeReport("worldvis");
 
        R_MarkEntities();
-       R_TimeReport("markentity");
+       if (r_timereport_active)
+               R_TimeReport("markentity");
 
        R_Shadow_UpdateWorldLightSelection();
 
@@ -1216,21 +1221,25 @@ void R_RenderScene(void)
                        if (r_refdef.extraupdate)
                                S_ExtraUpdate ();
 
-                       GL_ShowTrisColor(0.025, 0.025, 0, 1);
+                       if (r_showtrispass)
+                               GL_ShowTrisColor(0.025, 0.025, 0, 1);
                        if (r_refdef.worldmodel && r_refdef.worldmodel->DrawSky)
                        {
                                r_refdef.worldmodel->DrawSky(r_refdef.worldentity);
-                               R_TimeReport("worldsky");
+                               if (r_timereport_active)
+                                       R_TimeReport("worldsky");
                        }
 
-                       if (R_DrawBrushModelsSky())
+                       if (R_DrawBrushModelsSky() && r_timereport_active)
                                R_TimeReport("bmodelsky");
 
-                       GL_ShowTrisColor(0.05, 0.05, 0.05, 1);
+                       if (r_showtrispass)
+                               GL_ShowTrisColor(0.05, 0.05, 0.05, 1);
                        if (r_refdef.worldmodel && r_refdef.worldmodel->Draw)
                        {
                                r_refdef.worldmodel->Draw(r_refdef.worldentity);
-                               R_TimeReport("world");
+                               if (r_timereport_active)
+                                       R_TimeReport("world");
                        }
                }
 
@@ -1238,49 +1247,60 @@ void R_RenderScene(void)
                if (r_refdef.extraupdate)
                        S_ExtraUpdate ();
 
-               GL_ShowTrisColor(0, 0.015, 0, 1);
+               if (r_showtrispass)
+                       GL_ShowTrisColor(0, 0.015, 0, 1);
 
                R_DrawModels();
-               R_TimeReport("models");
+               if (r_timereport_active)
+                       R_TimeReport("models");
 
                // don't let sound skip if going slow
                if (r_refdef.extraupdate)
                        S_ExtraUpdate ();
 
-               GL_ShowTrisColor(0, 0, 0.033, 1);
+               if (r_showtrispass)
+                       GL_ShowTrisColor(0, 0, 0.033, 1);
                R_ShadowVolumeLighting(false);
-               R_TimeReport("rtlights");
+               if (r_timereport_active)
+                       R_TimeReport("rtlights");
 
                // don't let sound skip if going slow
                if (r_refdef.extraupdate)
                        S_ExtraUpdate ();
 
-               GL_ShowTrisColor(0.1, 0, 0, 1);
+               if (r_showtrispass)
+                       GL_ShowTrisColor(0.1, 0, 0, 1);
 
                if (cl.csqc_vidvars.drawworld)
                {
                        R_DrawLightningBeams();
-                       R_TimeReport("lightning");
+                       if (r_timereport_active)
+                               R_TimeReport("lightning");
 
                        R_DrawParticles();
-                       R_TimeReport("particles");
+                       if (r_timereport_active)
+                               R_TimeReport("particles");
 
                        R_DrawExplosions();
-                       R_TimeReport("explosions");
+                       if (r_timereport_active)
+                               R_TimeReport("explosions");
                }
 
                R_MeshQueue_RenderTransparent();
-               R_TimeReport("drawtrans");
+               if (r_timereport_active)
+                       R_TimeReport("drawtrans");
 
                if (cl.csqc_vidvars.drawworld)
                {
                        R_DrawCoronas();
-                       R_TimeReport("coronas");
+                       if (r_timereport_active)
+                               R_TimeReport("coronas");
                }
                if(cl.csqc_vidvars.drawcrosshair)
                {
                        R_DrawWorldCrosshair();
-                       R_TimeReport("crosshair");
+                       if (r_timereport_active)
+                               R_TimeReport("crosshair");
                }
 
                VM_AddPolygonsToMeshQueue();
@@ -1312,7 +1332,7 @@ void R_DrawBBoxMesh(vec3_t mins, vec3_t maxs, float cr, float cg, float cb, floa
        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        GL_DepthMask(false);
        GL_DepthTest(true);
-       R_Mesh_Matrix(&r_identitymatrix);
+       R_Mesh_Matrix(&identitymatrix);
 
        vertex3f[ 0] = mins[0];vertex3f[ 1] = mins[1];vertex3f[ 2] = mins[2];
        vertex3f[ 3] = maxs[0];vertex3f[ 4] = mins[1];vertex3f[ 5] = mins[2];
@@ -1477,7 +1497,7 @@ void R_DrawSprite(int blendfunc1, int blendfunc2, rtexture_t *texture, rtexture_
                fog = VERTEXFOGTABLE(VectorDistance(origin, r_vieworigin));
        ifog = 1 - fog;
 
-       R_Mesh_Matrix(&r_identitymatrix);
+       R_Mesh_Matrix(&identitymatrix);
        GL_BlendFunc(blendfunc1, blendfunc2);
        GL_DepthMask(false);
        GL_DepthTest(!depthdisable);
@@ -1569,7 +1589,7 @@ void R_Mesh_AddBrushMeshFromPlanes(rmesh_t *mesh, int numplanes, mplane_t *plane
                {
                        if (planenum2 == planenum)
                                continue;
-                       PolygonF_Divide(tempnumpoints, temppoints[w], plane2->normal[0], plane2->normal[1], plane2->normal[2], plane2->dist, 1.0/32.0, 0, NULL, NULL, 256, temppoints[!w], &tempnumpoints);
+                       PolygonF_Divide(tempnumpoints, temppoints[w], plane2->normal[0], plane2->normal[1], plane2->normal[2], plane2->dist, 1.0/32.0, 0, NULL, NULL, 256, temppoints[!w], &tempnumpoints, NULL);
                        w = !w;
                }
                if (tempnumpoints < 3)
@@ -1635,17 +1655,17 @@ void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t)
        if (t->currentmaterialflags & MATERIALFLAG_WATER && r_waterscroll.value != 0)
                t->currenttexmatrix = r_waterscrollmatrix;
        else
-               t->currenttexmatrix = r_identitymatrix;
+               t->currenttexmatrix = identitymatrix;
        t->currentnumlayers = 0;
        if (!(t->currentmaterialflags & MATERIALFLAG_NODRAW))
        {
                if (gl_lightmaps.integer)
-                       R_Texture_AddLayer(t, true, GL_ONE, GL_ZERO, TEXTURELAYERTYPE_LITTEXTURE_MULTIPASS, r_texture_white, &r_identitymatrix, 1, 1, 1, 1);
+                       R_Texture_AddLayer(t, true, GL_ONE, GL_ZERO, TEXTURELAYERTYPE_LITTEXTURE_MULTIPASS, r_texture_white, &identitymatrix, 1, 1, 1, 1);
                else if (t->currentmaterialflags & MATERIALFLAG_SKY)
                {
                        // transparent sky would be ridiculous
                        if (!(t->currentmaterialflags & MATERIALFLAG_TRANSPARENT))
-                               R_Texture_AddLayer(t, true, GL_ONE, GL_ZERO, TEXTURELAYERTYPE_SKY, r_texture_white, &r_identitymatrix, fogcolor[0], fogcolor[1], fogcolor[2], 1);
+                               R_Texture_AddLayer(t, true, GL_ONE, GL_ZERO, TEXTURELAYERTYPE_SKY, r_texture_white, &identitymatrix, fogcolor[0], fogcolor[1], fogcolor[2], 1);
                }
                else
                {
@@ -1730,7 +1750,7 @@ void R_UpdateTextureInfo(const entity_render_t *ent, texture_t *t)
                                        // were darkened by fog already, and we should not add fog color
                                        // (because the background was not darkened, there is no fog color
                                        // that was lost behind it).
-                                       R_Texture_AddLayer(t, false, GL_SRC_ALPHA, (t->currentmaterialflags & MATERIALFLAG_TRANSPARENT) ? GL_ONE : GL_ONE_MINUS_SRC_ALPHA, TEXTURELAYERTYPE_FOG, t->skin.fog, &r_identitymatrix, fogcolor[0], fogcolor[1], fogcolor[2], t->currentalpha);
+                                       R_Texture_AddLayer(t, false, GL_SRC_ALPHA, (t->currentmaterialflags & MATERIALFLAG_TRANSPARENT) ? GL_ONE : GL_ONE_MINUS_SRC_ALPHA, TEXTURELAYERTYPE_FOG, t->skin.fog, &identitymatrix, fogcolor[0], fogcolor[1], fogcolor[2], t->currentalpha);
                                }
                        }
                }