]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_screen.c
lhnet fixes - now calls WSAStartup during LHNET_Init and WSAShutdown during LHNET_Shu...
[xonotic/darkplaces.git] / cl_screen.c
index 63b8e94e94d0d04483e6bcd920c230ba7852f09c..eccb767a67674a7f0a86fa82eb5471b879bfc1e2 100644 (file)
@@ -8,9 +8,8 @@
 
 cvar_t scr_viewsize = {CVAR_SAVE, "viewsize","100", "how large the view should be, 110 disables inventory bar, 120 disables status bar"};
 cvar_t scr_fov = {CVAR_SAVE, "fov","90", "field of vision, 1-170 degrees, default 90, some players use 110-130"};      // 1 - 170
-cvar_t scr_conspeed = {CVAR_SAVE, "scr_conspeed","900", "speed of console open/close"}; // LordHavoc: quake used 300
 cvar_t scr_conalpha = {CVAR_SAVE, "scr_conalpha", "1", "opacity of console background"};
-cvar_t scr_conbrightness = {CVAR_SAVE, "scr_conbrightness", "0.2", "brightness of console background (0 = black, 1 = image)"};
+cvar_t scr_conbrightness = {CVAR_SAVE, "scr_conbrightness", "1", "brightness of console background (0 = black, 1 = image)"};
 cvar_t scr_conforcewhiledisconnected = {0, "scr_conforcewhiledisconnected", "1", "forces fullscreen console while disconnected"};
 cvar_t scr_menuforcewhiledisconnected = {0, "scr_menuforcewhiledisconnected", "0", "forces menu while disconnected"};
 cvar_t scr_centertime = {0, "scr_centertime","2", "how long centerprint messages show"};
@@ -24,9 +23,9 @@ cvar_t vid_conheight = {CVAR_SAVE, "vid_conheight", "480", "virtual height of 2D
 cvar_t vid_pixelheight = {CVAR_SAVE, "vid_pixelheight", "1", "adjusts vertical field of vision to account for non-square pixels (1280x1024 on a CRT monitor for example)"};
 cvar_t scr_screenshot_jpeg = {CVAR_SAVE, "scr_screenshot_jpeg","1", "save jpeg instead of targa"};
 cvar_t scr_screenshot_jpeg_quality = {CVAR_SAVE, "scr_screenshot_jpeg_quality","0.9", "image quality of saved jpeg"};
-cvar_t scr_screenshot_gamma = {CVAR_SAVE, "scr_screenshot_gamma","2.2", "gamma correction on saved screenshots and videos, 1.0 saves unmodified images"};
+cvar_t scr_screenshot_gammaboost = {CVAR_SAVE, "scr_screenshot_gammaboost","1", "gamma correction on saved screenshots and videos, 1.0 saves unmodified images"};
 // scr_screenshot_name is defined in fs.c
-cvar_t cl_capturevideo = {0, "cl_capturevideo", "0", "enables saving of video to a file or files (default is .tga files, if scr_screenshot_jpeg is on it saves .jpg files (VERY SLOW), if any rawrgb or rawyv12 are on it saves those formats instead, note that scr_screenshot_gamma affects the brightness of the output)"};
+cvar_t cl_capturevideo = {0, "cl_capturevideo", "0", "enables saving of video to a file or files (default is .tga files, if scr_screenshot_jpeg is on it saves .jpg files (VERY SLOW), if any rawrgb or rawyv12 are on it saves those formats instead, note that scr_screenshot_gammaboost affects the brightness of the output)"};
 cvar_t cl_capturevideo_sound = {0, "cl_capturevideo_sound", "0", "enables saving of sound to a .wav file (warning: this requires exact sync, if your hard drive can't keep up it will abort, if your graphics can't keep up it will save duplicate frames to maintain sound sync)"};
 cvar_t cl_capturevideo_fps = {0, "cl_capturevideo_fps", "30", "how many frames per second to save (29.97 for NTSC, 30 for typical PC video, 15 can be useful)"};
 cvar_t cl_capturevideo_rawrgb = {0, "cl_capturevideo_rawrgb", "0", "saves a single .rgb video file containing raw RGB images (you'll need special processing tools to encode this to something more useful)"};
@@ -157,7 +156,7 @@ void SCR_CheckDrawCenterString (void)
        if (scr_center_lines > scr_erase_lines)
                scr_erase_lines = scr_center_lines;
 
-       scr_centertime_off -= host_frametime;
+       scr_centertime_off -= cl.realframetime;
 
        // don't draw if this is a normal stats-screen intermission,
        // only if it is not an intermission, or a finale intermission
@@ -186,7 +185,7 @@ void SCR_DrawTurtle (void)
        if (!scr_showturtle.integer)
                return;
 
-       if (host_frametime < 0.1)
+       if (cl.realframetime < 0.1)
        {
                count = 0;
                return;
@@ -352,24 +351,7 @@ void SCR_SetUpToDrawConsole (void)
        else
                conlines = 0;                           // none visible
 
-       if (scr_conspeed.value)
-       {
-               if (scr_con_current > conlines)
-               {
-                       scr_con_current -= scr_conspeed.value*host_realframetime;
-                       if (scr_con_current < conlines)
-                               scr_con_current = conlines;
-
-               }
-               else if (scr_con_current < conlines)
-               {
-                       scr_con_current += scr_conspeed.value*host_realframetime;
-                       if (scr_con_current > conlines)
-                               scr_con_current = conlines;
-               }
-       }
-       else
-               scr_con_current = conlines;
+       scr_con_current = conlines;
 }
 
 /*
@@ -425,7 +407,8 @@ void R_TimeReport(char *desc)
        if (r_speeds.integer < 2 || !r_timereport_active)
                return;
 
-       qglFinish();
+       CHECKGLERROR
+       qglFinish();CHECKGLERROR
        r_timereport_temp = r_timereport_current;
        r_timereport_current = Sys_DoubleTime();
        t = (int) ((r_timereport_current - r_timereport_temp) * 1000000.0 + 0.5);
@@ -528,7 +511,6 @@ void CL_Screen_Init(void)
 {
        Cvar_RegisterVariable (&scr_fov);
        Cvar_RegisterVariable (&scr_viewsize);
-       Cvar_RegisterVariable (&scr_conspeed);
        Cvar_RegisterVariable (&scr_conalpha);
        Cvar_RegisterVariable (&scr_conbrightness);
        Cvar_RegisterVariable (&scr_conforcewhiledisconnected);
@@ -544,7 +526,7 @@ void CL_Screen_Init(void)
        Cvar_RegisterVariable (&vid_pixelheight);
        Cvar_RegisterVariable (&scr_screenshot_jpeg);
        Cvar_RegisterVariable (&scr_screenshot_jpeg_quality);
-       Cvar_RegisterVariable (&scr_screenshot_gamma);
+       Cvar_RegisterVariable (&scr_screenshot_gammaboost);
        Cvar_RegisterVariable (&cl_capturevideo);
        Cvar_RegisterVariable (&cl_capturevideo_sound);
        Cvar_RegisterVariable (&cl_capturevideo_fps);
@@ -635,7 +617,7 @@ void SCR_CaptureVideo_BeginVideo(void)
        cls.capturevideo_soundrate = 0;
        cls.capturevideo_frame = 0;
        cls.capturevideo_buffer = (unsigned char *)Mem_Alloc(tempmempool, vid.width * vid.height * (3+3+3) + 18);
-       gamma = 1.0/scr_screenshot_gamma.value;
+       gamma = 1.0/scr_screenshot_gammaboost.value;
 
        /*
        for (i = 0;i < 256;i++)
@@ -776,14 +758,14 @@ qboolean SCR_CaptureVideo_VideoFrame(int newframenum)
        unsigned char *b, *out;
        char filename[32];
        int outoffset = (width/2)*(height/2);
+       CHECKGLERROR
        //return SCR_ScreenShot(filename, cls.capturevideo_buffer, cls.capturevideo_buffer + vid.width * vid.height * 3, cls.capturevideo_buffer + vid.width * vid.height * 6, 0, 0, vid.width, vid.height, false, false, false, jpeg, true);
        // speed is critical here, so do saving as directly as possible
        switch (cls.capturevideo_format)
        {
        case CAPTUREVIDEOFORMAT_RAWYV12:
                // FIXME: width/height must be multiple of 2, enforce this?
-               qglReadPixels (x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, cls.capturevideo_buffer);
-               CHECKGLERROR
+               qglReadPixels (x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, cls.capturevideo_buffer);CHECKGLERROR
                // process one line at a time, and CbCr every other line at 2 pixel intervals
                for (y = 0;y < height;y++)
                {
@@ -824,15 +806,13 @@ qboolean SCR_CaptureVideo_VideoFrame(int newframenum)
                                return false;
                return true;
        case CAPTUREVIDEOFORMAT_RAWRGB:
-               qglReadPixels (x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, cls.capturevideo_buffer);
-               CHECKGLERROR
+               qglReadPixels (x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, cls.capturevideo_buffer);CHECKGLERROR
                for (;cls.capturevideo_frame < newframenum;cls.capturevideo_frame++)
                        if (!FS_Write (cls.capturevideo_videofile, cls.capturevideo_buffer, width*height*3))
                                return false;
                return true;
        case CAPTUREVIDEOFORMAT_JPEG:
-               qglReadPixels (x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, cls.capturevideo_buffer);
-               CHECKGLERROR
+               qglReadPixels (x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, cls.capturevideo_buffer);CHECKGLERROR
                for (;cls.capturevideo_frame < newframenum;cls.capturevideo_frame++)
                {
                        sprintf(filename, "video/dp%06d.jpg", cls.capturevideo_frame);
@@ -849,8 +829,7 @@ qboolean SCR_CaptureVideo_VideoFrame(int newframenum)
                cls.capturevideo_buffer[14] = (height >> 0) & 0xFF;
                cls.capturevideo_buffer[15] = (height >> 8) & 0xFF;
                cls.capturevideo_buffer[16] = 24;       // pixel size
-               qglReadPixels (x, y, width, height, GL_BGR, GL_UNSIGNED_BYTE, cls.capturevideo_buffer + 18);
-               CHECKGLERROR
+               qglReadPixels (x, y, width, height, GL_BGR, GL_UNSIGNED_BYTE, cls.capturevideo_buffer + 18);CHECKGLERROR
                for (;cls.capturevideo_frame < newframenum;cls.capturevideo_frame++)
                {
                        sprintf(filename, "video/dp%06d.tga", cls.capturevideo_frame);
@@ -1103,13 +1082,13 @@ qboolean SCR_ScreenShot(char *filename, unsigned char *buffer1, unsigned char *b
        if (!r_render.integer)
                return false;
 
-       qglReadPixels (x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, buffer1);
        CHECKGLERROR
+       qglReadPixels (x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, buffer1);CHECKGLERROR
 
-       if (scr_screenshot_gamma.value != 1 && gammacorrect)
+       if (scr_screenshot_gammaboost.value != 1 && gammacorrect)
        {
                int i;
-               double igamma = 1.0 / scr_screenshot_gamma.value;
+               double igamma = 1.0 / scr_screenshot_gammaboost.value;
                unsigned char ramp[256];
                for (i = 0;i < 256;i++)
                        ramp[i] = (unsigned char) (pow(i * (1.0 / 255.0), igamma) * 255.0);
@@ -1134,11 +1113,15 @@ void R_ClearScreen(void)
        if (r_render.integer)
        {
                // clear to black
+               CHECKGLERROR
                if (fogenabled)
-                       qglClearColor(fogcolor[0],fogcolor[1],fogcolor[2],0);
+               {
+                       qglClearColor(fogcolor[0],fogcolor[1],fogcolor[2],0);CHECKGLERROR
+               }
                else
-                       qglClearColor(0,0,0,0);
-               CHECKGLERROR
+               {
+                       qglClearColor(0,0,0,0);CHECKGLERROR
+               }
                qglClearDepth(1);CHECKGLERROR
                if (gl_stencil)
                {
@@ -1290,20 +1273,20 @@ void SCR_UpdateLoadingScreen (void)
 {
        float x, y;
        cachepic_t *pic;
-       rmeshstate_t m;
        float vertex3f[12];
        float texcoord2f[8];
        // don't do anything if not initialized yet
        if (vid_hidden)
                return;
-       qglViewport(0, 0, vid.width, vid.height);
-       //qglDisable(GL_SCISSOR_TEST);
-       //qglDepthMask(1);
-       qglColorMask(1,1,1,1);
-       //qglClearColor(0,0,0,0);
-       //qglClear(GL_COLOR_BUFFER_BIT);
-       //qglCullFace(GL_FRONT);
-       //qglDisable(GL_CULL_FACE);
+       CHECKGLERROR
+       qglViewport(0, 0, vid.width, vid.height);CHECKGLERROR
+       //qglDisable(GL_SCISSOR_TEST);CHECKGLERROR
+       //qglDepthMask(1);CHECKGLERROR
+       qglColorMask(1,1,1,1);CHECKGLERROR
+       //qglClearColor(0,0,0,0);CHECKGLERROR
+       //qglClear(GL_COLOR_BUFFER_BIT);CHECKGLERROR
+       //qglCullFace(GL_FRONT);CHECKGLERROR
+       //qglDisable(GL_CULL_FACE);CHECKGLERROR
        //R_ClearScreen();
        R_Textures_Frame();
        GL_SetupView_Mode_Ortho(0, 0, vid_conwidth.integer, vid_conheight.integer, -10, 100);
@@ -1316,11 +1299,11 @@ void SCR_UpdateLoadingScreen (void)
        GL_Color(1,1,1,1);
        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        GL_DepthTest(false);
-       memset(&m, 0, sizeof(m));
-       m.pointer_vertex = vertex3f;
-       m.pointer_texcoord[0] = texcoord2f;
-       m.tex[0] = R_GetTexture(pic->tex);
-       R_Mesh_State(&m);
+       R_Mesh_VertexPointer(vertex3f);
+       R_Mesh_ColorPointer(NULL);
+       R_Mesh_ResetTextureState();
+       R_Mesh_TexBind(0, R_GetTexture(pic->tex));
+       R_Mesh_TexCoordPointer(0, 2, texcoord2f);
        vertex3f[2] = vertex3f[5] = vertex3f[8] = vertex3f[11] = 0;
        vertex3f[0] = vertex3f[9] = x;
        vertex3f[1] = vertex3f[4] = y;
@@ -1410,13 +1393,12 @@ void CL_UpdateScreen(void)
                R_TimeReport("start");
 
        CHECKGLERROR
-       qglViewport(0, 0, vid.width, vid.height);
-       qglDisable(GL_SCISSOR_TEST);
-       qglDepthMask(1);
-       qglColorMask(1,1,1,1);
-       qglClearColor(0,0,0,0);
-       qglClear(GL_COLOR_BUFFER_BIT);
-       CHECKGLERROR
+       qglViewport(0, 0, vid.width, vid.height);CHECKGLERROR
+       qglDisable(GL_SCISSOR_TEST);CHECKGLERROR
+       qglDepthMask(1);CHECKGLERROR
+       qglColorMask(1,1,1,1);CHECKGLERROR
+       qglClearColor(0,0,0,0);CHECKGLERROR
+       qglClear(GL_COLOR_BUFFER_BIT);CHECKGLERROR
 
        if (r_timereport_active)
                R_TimeReport("clear");