]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_rmain.c
rewrite of map texture loading (mainly to do with HL textures and wads)
[xonotic/darkplaces.git] / gl_rmain.c
index c2836b8718e08983da0b8e498443a099ac395eb7..11a1c481cc255973d7946c656d628386afbb506d 100644 (file)
@@ -33,7 +33,7 @@ int                   r_framecount;           // used for dlight push checking
 
 mplane_t       frustum[4];
 
-int                    c_brush_polys, c_alias_polys, c_light_polys, c_nodes, c_leafs;
+int                    c_brush_polys, c_alias_polys, c_light_polys, c_faces, c_nodes, c_leafs, c_models, c_bmodels, c_sprites, c_particles, c_dlights;
 
 qboolean       envmap;                         // true during envmap command capture 
 
@@ -80,9 +80,9 @@ cvar_t        r_novis = {"r_novis","0"};
 cvar_t r_waterripple = {"r_waterripple","0"};
 cvar_t r_fullbrights = {"r_fullbrights", "1"};
 
-cvar_t contrast = {"contrast", "1.0", TRUE}; // LordHavoc: a method of operating system independent color correction
-cvar_t brightness = {"brightness", "1.0", TRUE}; // LordHavoc: a method of operating system independent color correction
-cvar_t gl_lightmode = {"gl_lightmode", "1", TRUE}; // LordHavoc: overbright lighting
+cvar_t contrast = {"contrast", "1.0", true}; // LordHavoc: a method of operating system independent color correction
+cvar_t brightness = {"brightness", "1.0", true}; // LordHavoc: a method of operating system independent color correction
+cvar_t gl_lightmode = {"gl_lightmode", "1", true}; // LordHavoc: overbright lighting
 //cvar_t       r_dynamicbothsides = {"r_dynamicbothsides", "1"}; // LordHavoc: can disable dynamic lighting of backfaces, but quake maps are weird so it doesn't always work right...
 cvar_t r_farclip = {"r_farclip", "6144"};
 
@@ -223,6 +223,10 @@ void glmain_shutdown()
 void GL_Main_Init()
 {
        FOG_registercvars();
+       Cvar_RegisterVariable (&r_drawentities);
+       Cvar_RegisterVariable (&r_drawviewmodel);
+       Cvar_RegisterVariable (&r_shadows);
+       Cvar_RegisterVariable (&r_speeds);
        Cvar_RegisterVariable (&r_speeds2);
        Cvar_RegisterVariable (&contrast);
        Cvar_RegisterVariable (&brightness);
@@ -230,6 +234,10 @@ void GL_Main_Init()
 //     Cvar_RegisterVariable (&r_dynamicwater);
 //     Cvar_RegisterVariable (&r_dynamicbothsides);
        Cvar_RegisterVariable (&r_fullbrights);
+       Cvar_RegisterVariable (&r_wateralpha);
+       Cvar_RegisterVariable (&r_dynamic);
+       Cvar_RegisterVariable (&r_novis);
+       Cvar_RegisterVariable (&r_waterripple); // LordHavoc: added waterripple
        if (nehahra)
                Cvar_SetValue("r_fullbrights", 0);
 //     if (gl_vendor && strstr(gl_vendor, "3Dfx"))
@@ -248,6 +256,7 @@ extern void GL_Misc_Init();
 extern void R_Crosshairs_Init();
 extern void R_Light_Init();
 extern void R_Particles_Init();
+extern void R_Explosion_Init();
 
 void Render_Init()
 {
@@ -262,6 +271,7 @@ void Render_Init()
        R_Crosshairs_Init();
        R_Light_Init();
        R_Particles_Init();
+       R_Explosion_Init();
        R_StartModules();
 }
 
@@ -285,7 +295,7 @@ void GL_Init (void)
 
 //     Con_Printf ("%s %s\n", gl_renderer, gl_version);
 
-       VID_CheckMultiTexture();
+       VID_CheckMultitexture();
        VID_CheckVertexArrays();
 
        // LordHavoc: report supported extensions
@@ -372,7 +382,7 @@ void R_DrawEntitiesOnList2 (void)
                switch (currententity->model->type)
                {
                case mod_alias:
-                       R_DrawAliasModel (currententity, true, modelalpha, currententity->model, currententity->frame, currententity->skinnum, currententity->origin, currententity->effects, currententity->model->flags, currententity->colormap);
+                       R_DrawAliasModel (currententity, true, modelalpha, currententity->model, currententity->frame, currententity->skinnum, currententity->origin, currententity->angles, currententity->effects, currententity->model->flags, currententity->colormap);
                        break;
 
                case mod_sprite:
@@ -403,7 +413,7 @@ void R_DrawViewModel (void)
 
        // hack the depth range to prevent view model from poking into walls
        glDepthRange (gldepthmin, gldepthmin + 0.3*(gldepthmax-gldepthmin));
-       R_DrawAliasModel (currententity, FALSE, modelalpha, currententity->model, currententity->frame, currententity->skinnum, currententity->origin, currententity->effects, currententity->model->flags, currententity->colormap);
+       R_DrawAliasModel (currententity, false, modelalpha, currententity->model, currententity->frame, currententity->skinnum, currententity->origin, currententity->angles, currententity->effects, currententity->model->flags, currententity->colormap);
        glDepthRange (gldepthmin, gldepthmax);
 }
 
@@ -484,9 +494,14 @@ void R_SetupFrame (void)
        c_brush_polys = 0;
        c_alias_polys = 0;
        c_light_polys = 0;
+       c_faces = 0;
        c_nodes = 0;
        c_leafs = 0;
-
+       c_models = 0;
+       c_bmodels = 0;
+       c_sprites = 0;
+       c_particles = 0;
+//     c_dlights = 0;
 }
 
 
@@ -586,10 +601,6 @@ void R_SetupGL (void)
        glShadeModel(GL_SMOOTH);
 }
 
-void R_DrawWorld (void);
-//void R_RenderDlights (void);
-void R_DrawParticles (void);
-
 /*
 =============
 R_Clear
@@ -680,6 +691,7 @@ void GL_BlendView()
        glEnable(GL_TEXTURE_2D);
 }
 
+/*
 #define TIMEREPORT(DESC) \
        if (r_speeds2.value)\
        {\
@@ -688,6 +700,16 @@ void GL_BlendView()
                temptime += currtime;\
                Con_Printf(DESC " %.4fms ", temptime * 1000.0);\
        }
+*/
+#define TIMEREPORT(VAR) \
+       if (r_speeds2.value)\
+       {\
+               temptime = currtime;\
+               currtime = Sys_FloatTime();\
+               VAR = (int) ((currtime - temptime) * 1000000.0);\
+       }\
+       else\
+               VAR = 0;
 
 /*
 ================
@@ -700,8 +722,11 @@ extern qboolean intimerefresh;
 extern qboolean skyisvisible;
 extern void R_Sky();
 extern void UploadLightmaps();
+char r_speeds2_string1[81], r_speeds2_string2[81], r_speeds2_string3[81], r_speeds2_string4[81], r_speeds2_string5[81], r_speeds2_string6[81];
 void R_RenderView (void)
 {
+       double starttime, currtime, temptime;
+       int time_clear, time_setup, time_world, time_bmodels, time_upload, time_sky, time_wall, time_models, time_moveparticles, time_drawparticles, time_moveexplosions, time_drawexplosions, time_transpoly, time_blend, time_total;
 //     double currtime, temptime;
 //     if (r_norefresh.value)
 //             return;
@@ -713,47 +738,77 @@ void R_RenderView (void)
 
        FOG_framebegin();
 
-//     if (r_speeds2.value)
-//     {
-//             currtime = Sys_FloatTime();
+       if (r_speeds2.value)
+       {
+               starttime = currtime = Sys_FloatTime();
 //             Con_Printf("render time: ");
-//     }
+       }
+       else
+               starttime = currtime = 0;
        R_Clear();
-//     TIMEREPORT("R_Clear")
+       skypolyclear();
+       wallpolyclear();
+       transpolyclear();
+       skyisvisible = false;
+       TIMEREPORT(time_clear)
 
        // render normal view
 
        R_SetupFrame ();
        R_SetFrustum ();
        R_SetupGL ();
-
-       skypolyclear();
-       wallpolyclear();
-       transpolyclear();
-       skyisvisible = false;
+       TIMEREPORT(time_setup)
 
        R_MarkLeaves ();        // done here so we know if we're in water
        R_DrawWorld ();         // adds static entities to the list
-       if (!intimerefresh)
-               S_ExtraUpdate ();       // don't let sound get messed up if going slow
+       TIMEREPORT(time_world)
        R_DrawEntitiesOnList1 (); // BSP models
+       TIMEREPORT(time_bmodels)
+
+       UploadLightmaps();
+       TIMEREPORT(time_upload)
 
        skypolyrender(); // fogged sky polys, affects depth
+
        if (skyname[0] && skyisvisible && !fogenabled)
                R_Sky(); // does not affect depth, draws over the sky polys
+       TIMEREPORT(time_sky)
 
-       UploadLightmaps();
        wallpolyrender();
+       TIMEREPORT(time_wall)
+
+//     if (!intimerefresh)
+//             S_ExtraUpdate ();       // don't let sound get messed up if going slow
 
        R_DrawEntitiesOnList2 (); // other models
 //     R_RenderDlights ();
        R_DrawViewModel ();
+       TIMEREPORT(time_models)
+       R_MoveParticles ();
+       TIMEREPORT(time_moveparticles)
        R_DrawParticles ();
+       TIMEREPORT(time_drawparticles)
+       R_MoveExplosions();
+       TIMEREPORT(time_moveexplosions)
+       R_DrawExplosions();
+       TIMEREPORT(time_drawexplosions)
 
        transpolyrender();
+       TIMEREPORT(time_transpoly)
 
        FOG_frameend();
+
        GL_BlendView();
-//     if (r_speeds2.value)
+       TIMEREPORT(time_blend)
+       if (r_speeds2.value)
+       {
+               time_total = (int) ((Sys_FloatTime() - starttime) * 1000000.0);
 //             Con_Printf("\n");
+               sprintf(r_speeds2_string1, "%6i walls %6i dlitwalls %7i modeltris %7i transpoly\n", c_brush_polys, c_light_polys, c_alias_polys, currenttranspoly);
+               sprintf(r_speeds2_string2, "BSP: %6i faces %6i nodes %6i leafs\n", c_faces, c_nodes, c_leafs);
+               sprintf(r_speeds2_string3, "%4i models %4i bmodels %4i sprites %5i particles %3i dlights\n", c_models, c_bmodels, c_sprites, c_particles, c_dlights);
+               sprintf(r_speeds2_string4, "%6ius clear  %6ius setup  %6ius world  %6ius bmodel %6ius upload", time_clear, time_setup, time_world, time_bmodels, time_upload);
+               sprintf(r_speeds2_string5, "%6ius sky    %6ius wall   %6ius models %6ius mpart  %6ius dpart ", time_sky, time_wall, time_models, time_moveparticles, time_drawparticles);
+               sprintf(r_speeds2_string6, "%6ius trans  %6ius blend  %6ius total  %6ius permdl", time_transpoly, time_blend, time_total, time_models / max(c_models, 1));
+       }
 }