]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_screen.c
split r_shadow_realtime into r_shadow_realtime_world (which requires stencil) and...
[xonotic/darkplaces.git] / cl_screen.c
index 8e23cc53dac8d8c49841067fdbf8f010587b986e..ceffda767f343cc228ec50f75c9828e5e93fbd25 100644 (file)
@@ -1,6 +1,7 @@
 
 #include "quakedef.h"
 #include "cl_video.h"
+#include "jpeg.h"
 
 cvar_t scr_viewsize = {CVAR_SAVE, "viewsize","100"};
 cvar_t scr_fov = {CVAR_SAVE, "fov","90"};      // 10 - 170
@@ -11,6 +12,7 @@ cvar_t scr_showturtle = {CVAR_SAVE, "showturtle","0"};
 cvar_t scr_showpause = {CVAR_SAVE, "showpause","1"};
 cvar_t scr_printspeed = {0, "scr_printspeed","8"};
 cvar_t scr_2dresolution = {CVAR_SAVE, "scr_2dresolution", "1"};
+cvar_t scr_screenshot_jpeg = {CVAR_SAVE, "scr_screenshot_jpeg","0"};
 cvar_t cl_avidemo = {0, "cl_avidemo", "0"};
 
 qboolean       scr_initialized;                // ready to draw
@@ -353,7 +355,6 @@ void R_TimeReport(char *desc)
 extern int c_rt_lights, c_rt_clears, c_rt_scissored;
 extern int c_rt_shadowmeshes, c_rt_shadowtris, c_rt_lightmeshes, c_rt_lighttris;
 extern int c_rtcached_shadowmeshes, c_rtcached_shadowtris;
-extern int r_shadow_lightingmode;
 void R_TimeReport_Start(void)
 {
        r_timereport_active = r_speeds.integer && cls.signon == SIGNONS && cls.state == ca_connected;
@@ -371,16 +372,14 @@ void R_TimeReport_Start(void)
                        c_faces, c_nodes, c_leafs, c_light_polys,
                        c_models, c_bmodels, c_sprites, c_particles, c_dlights,
                        c_alias_polys, c_meshs, c_meshelements / 3);
-               if (r_shadow_lightingmode)
-               {
-                       sprintf(r_speeds_string + strlen(r_speeds_string),
-                               "realtime lighting:%4i lights%4i clears%4i scissored\n"
-                               "dynamic: %6i shadowmeshes%6i shadowtris%6i lightmeshes%6i lighttris\n"
-                               "precomputed: %6i shadowmeshes%6i shadowtris\n",
-                               c_rt_lights, c_rt_clears, c_rt_scissored,
-                               c_rt_shadowmeshes, c_rt_shadowtris, c_rt_lightmeshes, c_rt_lighttris,
-                               c_rtcached_shadowmeshes, c_rtcached_shadowtris);
-               }
+
+               sprintf(r_speeds_string + strlen(r_speeds_string),
+                       "realtime lighting:%4i lights%4i clears%4i scissored\n"
+                       "dynamic: %6i shadowmeshes%6i shadowtris%6i lightmeshes%6i lighttris\n"
+                       "precomputed: %6i shadowmeshes%6i shadowtris\n",
+                       c_rt_lights, c_rt_clears, c_rt_scissored,
+                       c_rt_shadowmeshes, c_rt_shadowtris, c_rt_lightmeshes, c_rt_lighttris,
+                       c_rtcached_shadowmeshes, c_rtcached_shadowtris);
 
                c_alias_polys = 0;
                c_light_polys = 0;
@@ -465,6 +464,7 @@ void CL_Screen_Init(void)
        Cvar_RegisterVariable (&scr_centertime);
        Cvar_RegisterVariable (&scr_printspeed);
        Cvar_RegisterVariable (&scr_2dresolution);
+       Cvar_RegisterVariable (&scr_screenshot_jpeg);
        Cvar_RegisterVariable (&cl_avidemo);
 
        Cmd_AddCommand ("sizeup",SCR_SizeUp_f);
@@ -476,7 +476,7 @@ void CL_Screen_Init(void)
 
        // HACK HACK HACK
        // load the image data for the player image in the config menu
-       dat = (qpic_t *)COM_LoadFile ("gfx/menuplyr.lmp", false);
+       dat = (qpic_t *)FS_LoadFile ("gfx/menuplyr.lmp", false);
        if (!dat)
                Sys_Error("unable to load gfx/menuplyr.lmp");
        SwapPic (dat);
@@ -815,23 +815,29 @@ void SCR_ScreenShot_f (void)
        static int i = 0;
        char filename[16];
        char checkname[MAX_OSPATH];
-//
-// find a file name to save it to
-//
+       const char* extens;
+       qboolean jpeg = (scr_screenshot_jpeg.integer != 0);
+
+       if (jpeg)
+               extens = "jpg";
+       else
+               extens = "tga";
+
+       // find a file name to save it to
        for (; i<=9999 ; i++)
        {
-               sprintf (filename, "dp%04i.tga", i);
-               sprintf (checkname, "%s/%s", com_gamedir, filename);
-               if (Sys_FileTime(checkname) == -1)
-                       break;  // file doesn't exist
+               sprintf (filename, "dp%04i.%s", i, extens);
+               sprintf (checkname, "%s/%s", fs_gamedir, filename);
+               if (!FS_SysFileExists(checkname))
+                       break;
        }
        if (i==10000)
        {
-               Con_Printf ("SCR_ScreenShot_f: Couldn't create a TGA file\n");
+               Con_Printf ("SCR_ScreenShot_f: Couldn't create the image file\n");
                return;
        }
 
-       if (SCR_ScreenShot(filename, vid.realx, vid.realy, vid.realwidth, vid.realheight))
+       if (SCR_ScreenShot (filename, vid.realx, vid.realy, vid.realwidth, vid.realheight, jpeg))
                Con_Printf ("Wrote %s\n", filename);
        else
                Con_Printf ("unable to write %s\n", filename);
@@ -843,7 +849,7 @@ void SCR_CaptureAVIDemo(void)
 {
        char filename[32];
        sprintf(filename, "dpavi%06d.tga", cl_avidemo_frame);
-       if (SCR_ScreenShot(filename, vid.realx, vid.realy, vid.realwidth, vid.realheight))
+       if (SCR_ScreenShot(filename, vid.realx, vid.realy, vid.realwidth, vid.realheight, false))
                cl_avidemo_frame++;
        else
        {
@@ -915,7 +921,7 @@ static void R_Envmap_f (void)
                VectorCopy(envmapinfo[j].angles, r_refdef.viewangles);
                R_ClearScreen();
                R_RenderView ();
-               SCR_ScreenShot(filename, vid.realx, vid.realy, size, size);
+               SCR_ScreenShot(filename, vid.realx, vid.realy, size, size, false);
        }
 
        envmap = false;