X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=cl_screen.c;h=9b0a0c144548602f5366a8eb80aa3ea4ea99c9c4;hb=a37cd455150d17f68eec25ae6fa57808d940f1ae;hp=fe6f765d1e20f0024263e5a070e6da9a3daa5295;hpb=c3edd749ac26c6322eafa8303e592df3c32ffd25;p=xonotic%2Fdarkplaces.git diff --git a/cl_screen.c b/cl_screen.c index fe6f765d..9b0a0c14 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -15,9 +15,18 @@ 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"}; -cvar_t scr_conalpha = {CVAR_SAVE, "scr_conalpha", "1", "opacity of console background"}; +cvar_t scr_conalpha = {CVAR_SAVE, "scr_conalpha", "1", "opacity of console background gfx/conback"}; +cvar_t scr_conalphafactor = {CVAR_SAVE, "scr_conalphafactor", "1", "opacity of console background gfx/conback relative to scr_conalpha; when 0, gfx/conback is not drawn"}; +cvar_t scr_conalpha2factor = {CVAR_SAVE, "scr_conalpha2factor", "0", "opacity of console background gfx/conback2 relative to scr_conalpha; when 0, gfx/conback2 is not drawn"}; +cvar_t scr_conalpha3factor = {CVAR_SAVE, "scr_conalpha3factor", "0", "opacity of console background gfx/conback3 relative to scr_conalpha; when 0, gfx/conback3 is not drawn"}; 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_conscroll_x = {CVAR_SAVE, "scr_conscroll_x", "0", "scroll speed of gfx/conback in x direction"}; +cvar_t scr_conscroll_y = {CVAR_SAVE, "scr_conscroll_y", "0", "scroll speed of gfx/conback in y direction"}; +cvar_t scr_conscroll2_x = {CVAR_SAVE, "scr_conscroll2_x", "0", "scroll speed of gfx/conback2 in x direction"}; +cvar_t scr_conscroll2_y = {CVAR_SAVE, "scr_conscroll2_y", "0", "scroll speed of gfx/conback2 in y direction"}; +cvar_t scr_conscroll3_x = {CVAR_SAVE, "scr_conscroll3_x", "0", "scroll speed of gfx/conback3 in x direction"}; +cvar_t scr_conscroll3_y = {CVAR_SAVE, "scr_conscroll3_y", "0", "scroll speed of gfx/conback3 in y direction"}; 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"}; cvar_t scr_showram = {CVAR_SAVE, "showram","1", "show ram icon if low on surface cache memory (not used)"}; @@ -687,7 +696,7 @@ int speedstringcount, r_timereport_active; double r_timereport_temp = 0, r_timereport_current = 0, r_timereport_start = 0; int r_speeds_longestitem = 0; -void R_TimeReport(char *desc) +void R_TimeReport(const char *desc) { char tempbuf[256]; int length; @@ -697,7 +706,7 @@ void R_TimeReport(char *desc) return; CHECKGLERROR - if (r_speeds.integer == 2) + if (r_speeds.integer == 2 && qglFinish) qglFinish(); CHECKGLERROR r_timereport_temp = r_timereport_current; @@ -802,6 +811,7 @@ void R_TimeReport_EndFrame(void) lines++; y = vid_conheight.integer - sb_lines - lines * 8; i = j = 0; + r_draw2d_force = true; DrawQ_Fill(0, y, vid_conwidth.integer, lines * 8, 0, 0, 0, 0.5, 0); while (string[i]) { @@ -814,6 +824,7 @@ void R_TimeReport_EndFrame(void) i++; y += 8; } + r_draw2d_force = false; } } @@ -853,6 +864,15 @@ void CL_Screen_Init(void) Cvar_RegisterVariable (&scr_fov); Cvar_RegisterVariable (&scr_viewsize); Cvar_RegisterVariable (&scr_conalpha); + Cvar_RegisterVariable (&scr_conalphafactor); + Cvar_RegisterVariable (&scr_conalpha2factor); + Cvar_RegisterVariable (&scr_conalpha3factor); + Cvar_RegisterVariable (&scr_conscroll_x); + Cvar_RegisterVariable (&scr_conscroll_y); + Cvar_RegisterVariable (&scr_conscroll2_x); + Cvar_RegisterVariable (&scr_conscroll2_y); + Cvar_RegisterVariable (&scr_conscroll3_x); + Cvar_RegisterVariable (&scr_conscroll3_y); Cvar_RegisterVariable (&scr_conbrightness); Cvar_RegisterVariable (&scr_conforcewhiledisconnected); Cvar_RegisterVariable (&scr_menuforcewhiledisconnected); @@ -925,7 +945,6 @@ void SCR_ScreenShot_f (void) static char old_prefix_name[MAX_QPATH]; char prefix_name[MAX_QPATH]; char filename[MAX_QPATH]; - char mapname[MAX_QPATH]; unsigned char *buffer1; unsigned char *buffer2; qboolean jpeg = (scr_screenshot_jpeg.integer != 0); @@ -960,15 +979,10 @@ void SCR_ScreenShot_f (void) else { // TODO maybe make capturevideo and screenshot use similar name patterns? - if (scr_screenshot_name_in_mapdir.integer && cl.worldmodel && *cl.worldmodel->name) { - // figure out the map's filename without path or extension - strlcpy(mapname, FS_FileWithoutPath(cl.worldmodel->name), sizeof(mapname)); - if (strrchr(mapname, '.')) - *(strrchr(mapname, '.')) = 0; - dpsnprintf (prefix_name, sizeof(prefix_name), "%s/%s", mapname, Sys_TimeString(scr_screenshot_name.string)); - } else { + if (scr_screenshot_name_in_mapdir.integer && cl.worldbasename[0]) + dpsnprintf (prefix_name, sizeof(prefix_name), "%s/%s", cl.worldbasename, Sys_TimeString(scr_screenshot_name.string)); + else dpsnprintf (prefix_name, sizeof(prefix_name), "%s", Sys_TimeString(scr_screenshot_name.string)); - } if (strcmp(old_prefix_name, prefix_name)) { @@ -992,14 +1006,14 @@ void SCR_ScreenShot_f (void) buffer1 = (unsigned char *)Mem_Alloc(tempmempool, vid.width * vid.height * 4); buffer2 = (unsigned char *)Mem_Alloc(tempmempool, vid.width * vid.height * (scr_screenshot_alpha.integer ? 4 : 3)); - if (SCR_ScreenShot (filename, buffer1, buffer2, 0, 0, vid.width, vid.height, false, false, false, jpeg, png, true, scr_screenshot_alpha.integer)) + if (SCR_ScreenShot (filename, buffer1, buffer2, 0, 0, vid.width, vid.height, false, false, false, jpeg, png, true, scr_screenshot_alpha.integer != 0)) Con_Printf("Wrote %s\n", filename); else { Con_Printf("Unable to write %s\n", filename); if(jpeg || png) { - if(SCR_ScreenShot (filename, buffer1, buffer2, 0, 0, vid.width, vid.height, false, false, false, false, false, true, scr_screenshot_alpha.integer)) + if(SCR_ScreenShot (filename, buffer1, buffer2, 0, 0, vid.width, vid.height, false, false, false, false, false, true, scr_screenshot_alpha.integer != 0)) { strlcpy(filename + strlen(filename) - 3, "tga", 4); Con_Printf("Wrote %s\n", filename); @@ -1217,7 +1231,8 @@ void SCR_CaptureVideo_VideoFrame(int newframestepframenum) CHECKGLERROR // speed is critical here, so do saving as directly as possible - qglReadPixels (x, y, vid.width, vid.height, GL_BGRA, GL_UNSIGNED_BYTE, cls.capturevideo.screenbuffer);CHECKGLERROR + GL_ReadPixelsBGRA(x, y, vid.width, vid.height, cls.capturevideo.screenbuffer); + SCR_ScaleDownBGRA (cls.capturevideo.screenbuffer, vid.width, vid.height, cls.capturevideo.outbuffer, width, height); cls.capturevideo.videoframes(newframestepframenum - cls.capturevideo.framestepframe); @@ -1299,7 +1314,7 @@ Grab six views for environment mapping tests struct envmapinfo_s { float angles[3]; - char *name; + const char *name; qboolean flipx, flipy, flipdiagonaly; } envmapinfo[12] = @@ -1444,7 +1459,7 @@ void SHOWLMP_drawall(void) int i; for (i = 0;i < cl.num_showlmps;i++) if (cl.showlmps[i].isactive) - DrawQ_Pic(cl.showlmps[i].x, cl.showlmps[i].y, Draw_CachePic (cl.showlmps[i].pic), 0, 0, 1, 1, 1, 1, 0); + DrawQ_Pic(cl.showlmps[i].x, cl.showlmps[i].y, Draw_CachePic_Flags (cl.showlmps[i].pic, CACHEPICFLAG_NOTPERSISTENT), 0, 0, 1, 1, 1, 1, 0); } /* @@ -1462,8 +1477,7 @@ qboolean SCR_ScreenShot(char *filename, unsigned char *buffer1, unsigned char *b int indices[4] = {0,1,2,3}; // BGRA qboolean ret; - CHECKGLERROR - qglReadPixels (x, y, width, height, GL_BGRA, GL_UNSIGNED_BYTE, buffer1);CHECKGLERROR + GL_ReadPixelsBGRA(x, y, width, height, buffer1); if(gammacorrect && (scr_screenshot_gammaboost.value != 1 || WANT_SCREENSHOT_HWGAMMA)) { @@ -1529,36 +1543,20 @@ qboolean SCR_ScreenShot(char *filename, unsigned char *buffer1, unsigned char *b extern void R_UpdateFogColor(void); void R_ClearScreen(qboolean fogcolor) { + float clearcolor[4]; // clear to black - CHECKGLERROR + Vector4Clear(clearcolor); if (fogcolor) { R_UpdateFogColor(); - qglClearColor(r_refdef.fogcolor[0],r_refdef.fogcolor[1],r_refdef.fogcolor[2],0);CHECKGLERROR - } - else - { - qglClearColor(0,0,0,0);CHECKGLERROR - } - qglClearDepth(1);CHECKGLERROR - if (vid.stencil) - { - // LordHavoc: we use a stencil centered around 128 instead of 0, - // to avoid clamping interfering with strange shadow volume - // drawing orders - qglClearStencil(128);CHECKGLERROR + VectorCopy(r_refdef.fogcolor, clearcolor); } + // clear depth is 1.0 + // LordHavoc: we use a stencil centered around 128 instead of 0, + // to avoid clamping interfering with strange shadow volume + // drawing orders // clear the screen - GL_Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | (vid.stencil ? GL_STENCIL_BUFFER_BIT : 0)); - // set dithering mode - if (gl_dither.integer) - { - qglEnable(GL_DITHER);CHECKGLERROR - } - else - { - qglDisable(GL_DITHER);CHECKGLERROR - } + GL_Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | (vid.stencil ? GL_STENCIL_BUFFER_BIT : 0), clearcolor, 1.0f, 128); } qboolean CL_VM_UpdateView (void); @@ -1779,7 +1777,7 @@ static void SCR_SetLoadingScreenTexture(void) loadingscreentexture_h = vid.height / (float) h; } - loadingscreentexture = R_LoadTexture2D(r_main_texturepool, "loadingscreentexture", w, h, NULL, TEXTYPE_COLORBUFFER, TEXF_FORCENEAREST | TEXF_CLAMP, NULL); + loadingscreentexture = R_LoadTexture2D(r_main_texturepool, "loadingscreentexture", w, h, NULL, TEXTYPE_COLORBUFFER, TEXF_RENDERTARGET | TEXF_FORCENEAREST | TEXF_CLAMP, -1, NULL); R_Mesh_CopyToTexture(loadingscreentexture, 0, 0, 0, 0, vid.width, vid.height); loadingscreentexture_vertex3f[2] = loadingscreentexture_vertex3f[5] = loadingscreentexture_vertex3f[8] = loadingscreentexture_vertex3f[11] = 0; @@ -1938,16 +1936,14 @@ static void SCR_DrawLoadingScreen_SharedSetup (qboolean clear) // release mouse grab while loading if (!vid.fullscreen) VID_SetMouse(false, false, false); - CHECKGLERROR +// CHECKGLERROR + r_refdef.draw2dstage = true; R_Viewport_InitOrtho(&viewport, &identitymatrix, 0, 0, vid.width, vid.height, 0, 0, vid_conwidth.integer, vid_conheight.integer, -10, 100, NULL); R_SetViewport(&viewport); - //qglDisable(GL_SCISSOR_TEST);CHECKGLERROR - //qglDepthMask(1);CHECKGLERROR - qglColorMask(1,1,1,1);CHECKGLERROR - qglClearColor(0,0,0,0);CHECKGLERROR + GL_ColorMask(1,1,1,1); // when starting up a new video mode, make sure the screen is cleared to black if (clear) - qglClear(GL_COLOR_BUFFER_BIT);CHECKGLERROR + GL_Clear(GL_COLOR_BUFFER_BIT, NULL, 1.0f, 0); R_Textures_Frame(); R_Mesh_Start(); R_EntityMatrix(&identitymatrix); @@ -1975,12 +1971,13 @@ static void SCR_DrawLoadingScreen (qboolean clear) GL_DepthTest(false); R_Mesh_ResetTextureState(); GL_Color(1,1,1,1); - R_Mesh_PrepareVertices_Generic_Arrays(4, loadingscreentexture_vertex3f, NULL, loadingscreentexture_texcoord2f); if(loadingscreentexture) { + R_Mesh_PrepareVertices_Generic_Arrays(4, loadingscreentexture_vertex3f, NULL, loadingscreentexture_texcoord2f); R_SetupShader_Generic(loadingscreentexture, NULL, GL_MODULATE, 1); R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, NULL, 0, polygonelement3s, NULL, 0); } + R_Mesh_PrepareVertices_Generic_Arrays(4, loadingscreenpic_vertex3f, NULL, loadingscreenpic_texcoord2f); R_SetupShader_Generic(loadingscreenpic->tex, NULL, GL_MODULATE, 1); R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, NULL, 0, polygonelement3s, NULL, 0); SCR_DrawLoadingStack(); @@ -1991,8 +1988,6 @@ static void SCR_DrawLoadingScreen_SharedFinish (qboolean clear) R_Mesh_Finish(); // refresh VID_Finish(); - // however this IS necessary on Windows Vista - qglFinish(); } void SCR_UpdateLoadingScreen (qboolean clear) @@ -2035,7 +2030,8 @@ void SCR_UpdateLoadingScreen (qboolean clear) } else { - qglDrawBuffer(GL_BACK); + if (qglDrawBuffer) + qglDrawBuffer(GL_BACK); SCR_DrawLoadingScreen(clear); } SCR_DrawLoadingScreen_SharedFinish(clear); @@ -2074,6 +2070,7 @@ void CL_UpdateScreen(void) double rendertime1; float conwidth, conheight; float f; + r_viewport_t viewport; Sbar_ShowFPS_Update(); @@ -2094,7 +2091,10 @@ void CL_UpdateScreen(void) } if (vid_hidden) + { + VID_Finish(); return; + } rendertime1 = Sys_DoubleTime(); @@ -2136,13 +2136,27 @@ void CL_UpdateScreen(void) SCR_SetUpToDrawConsole(); - CHECKGLERROR - qglDrawBuffer(GL_BACK);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 + if (qglDrawBuffer) + { + CHECKGLERROR + qglDrawBuffer(GL_BACK);CHECKGLERROR + // set dithering mode + if (gl_dither.integer) + { + qglEnable(GL_DITHER);CHECKGLERROR + } + else + { + qglDisable(GL_DITHER);CHECKGLERROR + } + } + + R_Viewport_InitOrtho(&viewport, &identitymatrix, 0, 0, vid.width, vid.height, 0, 0, vid_conwidth.integer, vid_conheight.integer, -10, 100, NULL); + R_SetViewport(&viewport); + GL_ScissorTest(false); + GL_ColorMask(1,1,1,1); + GL_DepthMask(true); + R_ClearScreen(false); r_refdef.view.clear = false; r_refdef.view.isoverlay = false; @@ -2176,7 +2190,6 @@ void CL_UpdateScreen(void) } } - CHECKGLERROR if (R_Stereo_Active()) { matrix4x4_t originalmatrix = r_refdef.view.matrix; @@ -2221,13 +2234,13 @@ void CL_UpdateScreen(void) } else SCR_DrawScreen(); - CHECKGLERROR SCR_CaptureVideo(); + if (qglFlush) + qglFlush(); // FIXME: should we really be using qglFlush here? + // quality adjustment according to render time - CHECKGLERROR - qglFlush(); // FIXME: should we really be using qglFlush here? cl_updatescreen_rendertime += ((Sys_DoubleTime() - rendertime1) - cl_updatescreen_rendertime) * bound(0, cl_minfps_fade.value, 1); if (cl_minfps.value > 0 && cl_updatescreen_rendertime > 0 && !cls.timedemo && (!cls.capturevideo.active || !cls.capturevideo.realtime)) cl_updatescreen_quality = 1 / (cl_updatescreen_rendertime * cl_minfps.value); @@ -2243,7 +2256,7 @@ void CL_UpdateScreen(void) else if (key_dest == key_menu) VID_SetMouse(vid.fullscreen, vid_mouse.integer && !in_client_mouse, true); else - VID_SetMouse(vid.fullscreen, vid_mouse.integer && !cl.csqc_wantsmousemove && (!cls.demoplayback || cl_demo_mousegrab.integer), true); + VID_SetMouse(vid.fullscreen, vid_mouse.integer && !cl.csqc_wantsmousemove && cl_prydoncursor.integer <= 0 && (!cls.demoplayback || cl_demo_mousegrab.integer), true); VID_Finish(); }