]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_screen.c
minor redesign of console loading/drawing, cruft removal, change to Draw_GenericPic...
[xonotic/darkplaces.git] / gl_screen.c
index ad3691a3a5e9297589a2c1e4543619740757faca..fed3a177523daa7190799c335eb73aa2bf09768e 100644 (file)
@@ -89,6 +89,7 @@ cvar_t                scr_showturtle = {"showturtle","0"};
 cvar_t         scr_showpause = {"showpause","1"};
 cvar_t         scr_printspeed = {"scr_printspeed","8"};
 cvar_t         showfps = {"showfps", "0", true};
+cvar_t         r_render = {"r_render", "1"};
 
 extern cvar_t  crosshair;
 
@@ -369,12 +370,23 @@ void SCR_SizeDown_f (void)
 
 //============================================================================
 
+void gl_screen_start()
+{
+       scr_ram = Draw_PicFromWad ("ram");
+       scr_net = Draw_PicFromWad ("net");
+       scr_turtle = Draw_PicFromWad ("turtle");
+}
+
+void gl_screen_shutdown()
+{
+}
+
 /*
 ==================
 SCR_Init
 ==================
 */
-void SCR_Init (void)
+void GL_Screen_Init (void)
 {
 
        Cvar_RegisterVariable (&scr_fov);
@@ -386,6 +398,10 @@ void SCR_Init (void)
        Cvar_RegisterVariable (&scr_centertime);
        Cvar_RegisterVariable (&scr_printspeed);
        Cvar_RegisterVariable (&showfps);
+       Cvar_RegisterVariable (&r_render);
+#ifdef NORENDER
+       r_render.value = 0;
+#endif
 
 //
 // register our commands
@@ -394,11 +410,9 @@ void SCR_Init (void)
        Cmd_AddCommand ("sizeup",SCR_SizeUp_f);
        Cmd_AddCommand ("sizedown",SCR_SizeDown_f);
 
-       scr_ram = Draw_PicFromWad ("ram");
-       scr_net = Draw_PicFromWad ("net");
-       scr_turtle = Draw_PicFromWad ("turtle");
-
        scr_initialized = true;
+
+       R_RegisterModule("GL_Screen", gl_screen_start, gl_screen_shutdown);
 }
 
 
@@ -623,7 +637,8 @@ void SCR_ScreenShot_f (void)
        buffer[15] = glheight>>8;
        buffer[16] = 24;        // pixel size
 
-       glReadPixels (glx, gly, glwidth, glheight, GL_RGB, GL_UNSIGNED_BYTE, buffer+18 ); 
+       if (r_render.value)
+               glReadPixels (glx, gly, glwidth, glheight, GL_RGB, GL_UNSIGNED_BYTE, buffer+18 ); 
 
        // swap rgb to bgr
        c = 18+glwidth*glheight*3;
@@ -780,9 +795,9 @@ void SCR_BringDownConsole (void)
                SCR_UpdateScreen ();
 
        cl.cshifts[0].percent = 0;              // no area contents palette on next frame
-       VID_SetPalette (host_basepal);
 }
 
+void DrawCrosshair(int num);
 void GL_Set2D (void);
 
 extern void SHOWLMP_drawall();
@@ -793,6 +808,8 @@ extern cvar_t gl_lightmode;
 void GL_BrightenScreen()
 {
        float f;
+       if (!r_render.value)
+               return;
        glDisable(GL_TEXTURE_2D);
        glEnable(GL_BLEND);
        f = brightness.value = bound(1.0f, brightness.value, 5.0f);
@@ -838,25 +855,18 @@ SCR_UpdateScreen
 This is called every frame, and can also be called explicitly to flush
 text to the screen.
 
-WARNING: be very careful calling this from elsewhere, because the refresh
-needs almost the entire 256k of stack space!
+LordHavoc: due to my rewrite of R_WorldNode, it no longer takes 256k of stack space :)
 ==================
 */
 extern cvar_t gl_vertexarrays;
 extern qboolean gl_arrays;
 void GL_Finish();
-int c_nodes;
 void SCR_UpdateScreen (void)
 {
        double  time1 = 0, time2;
 
        if (r_speeds.value)
-       {
                time1 = Sys_FloatTime ();
-               c_brush_polys = 0;
-               c_alias_polys = 0;
-               c_nodes = 0;
-       }
 
        if (!gl_arrays)
                gl_vertexarrays.value = 0;
@@ -899,8 +909,11 @@ void SCR_UpdateScreen (void)
        if (vid.recalc_refdef)
                SCR_CalcRefdef ();
 
-       glClearColor(0,0,0,0);
-       glClear (GL_COLOR_BUFFER_BIT); // LordHavoc: clear the screen (around the view as well)
+       if (r_render.value)
+       {
+               glClearColor(0,0,0,0);
+               glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // LordHavoc: clear the screen (around the view as well)
+       }
 
 //
 // do 3D refresh drawing, and then update the screen
@@ -935,7 +948,7 @@ void SCR_UpdateScreen (void)
        else
        {
                if (crosshair.value)
-                       Draw_Character (r_refdef.vrect.x + r_refdef.vrect.width/2, r_refdef.vrect.y + r_refdef.vrect.height/2, '+');
+                       DrawCrosshair(crosshair.value);
                
                SCR_DrawRam ();
                SCR_DrawNet ();
@@ -970,7 +983,7 @@ void SCR_UpdateScreen (void)
        if (r_speeds.value)
        {
                time2 = Sys_FloatTime ();
-               Con_Printf ("%3i ms  %4i wpoly %4i epoly %4i transpoly %4i BSPnodes\n", (int)((time2-time1)*1000), c_brush_polys, c_alias_polys, currenttranspoly, c_nodes); 
+               Con_Printf ("%3i ms  %4i wpoly %4i epoly %4i transpoly %4i lightpoly %4i BSPnodes %4i BSPleafs\n", (int)((time2-time1)*1000), c_brush_polys, c_alias_polys, currenttranspoly, c_light_polys, c_nodes, c_leafs);
        }
        GL_EndRendering ();
 }
@@ -978,6 +991,8 @@ void SCR_UpdateScreen (void)
 // for profiling, this is seperated
 void GL_Finish()
 {
+       if (!r_render.value)
+               return;
        glFinish ();
 }