From ec3d886864d793e63bb6c3aad6310ca600485f81 Mon Sep 17 00:00:00 2001 From: TimeServ Date: Sat, 25 Feb 2006 21:03:56 +0000 Subject: [PATCH] scr_conalpha added git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2022 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/cl_screen.c | 5 ++++ engine/client/renderer.c | 3 ++ engine/common/quakeasm.h | 2 +- engine/gl/gl_draw.c | 25 +++++++++++++---- engine/sw/d_part.c | 12 ++++---- engine/sw/d_parta.s | 2 +- engine/sw/d_varsa.s | 4 +-- engine/sw/sw_draw.c | 58 +++++++++++++++++++++++++++++++-------- 8 files changed, 83 insertions(+), 28 deletions(-) diff --git a/engine/client/cl_screen.c b/engine/client/cl_screen.c index 55831d973..3f5168124 100644 --- a/engine/client/cl_screen.c +++ b/engine/client/cl_screen.c @@ -94,6 +94,8 @@ int scr_copyeverything; float scr_con_current; float scr_conlines; // lines of console to display +qboolean scr_con_forcedraw; + float oldscreensize, oldfov; extern cvar_t scr_viewsize; extern cvar_t scr_fov; @@ -1336,6 +1338,8 @@ void SCR_SetUpToDrawConsole (void) #endif Con_CheckResize (); + scr_con_forcedraw = false; + if (scr_drawloading) return; // never a console with loading plaque @@ -1351,6 +1355,7 @@ void SCR_SetUpToDrawConsole (void) { scr_conlines = vid.height; // full screen scr_con_current = scr_conlines; + scr_con_forcedraw = true; } else if (key_dest == key_console || scr_chatmode) { diff --git a/engine/client/renderer.c b/engine/client/renderer.c index 150b93f19..0b7b0bad8 100644 --- a/engine/client/renderer.c +++ b/engine/client/renderer.c @@ -160,6 +160,8 @@ cvar_t scr_sshot_type = SCVAR("scr_sshot_type", "jpg"); cvar_t scr_centersbar = SCVAR("scr_centersbar", "0"); cvar_t scr_consize = SCVAR("scr_consize", "0.5"); +cvar_t scr_conalpha = SCVAR("scr_conalpha", "0.7"); + cvar_t scr_viewsize = SCVARF("viewsize","100", CVAR_ARCHIVE); cvar_t scr_fov = SCVARF("fov","90", CVAR_ARCHIVE); // 10 - 170 cvar_t scr_conspeed = SCVAR("scr_conspeed","300"); @@ -496,6 +498,7 @@ void Renderer_Init(void) //screen Cvar_Register (&scr_conspeed, SCREENOPTIONS); + Cvar_Register (&scr_conalpha, SCREENOPTIONS); Cvar_Register (&scr_showram, SCREENOPTIONS); Cvar_Register (&scr_showturtle, SCREENOPTIONS); Cvar_Register (&scr_showpause, SCREENOPTIONS); diff --git a/engine/common/quakeasm.h b/engine/common/quakeasm.h index 6b955eaa4..0680671fa 100644 --- a/engine/common/quakeasm.h +++ b/engine/common/quakeasm.h @@ -248,7 +248,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. .extern DP_Count .extern DP_u .extern DP_v - .extern DP_32768 + .extern DP_Partfac .extern DP_Color .extern DP_Pix .extern DP_EntryTable diff --git a/engine/gl/gl_draw.c b/engine/gl/gl_draw.c index 6ea47ff1b..c014ee3f5 100644 --- a/engine/gl/gl_draw.c +++ b/engine/gl/gl_draw.c @@ -74,6 +74,7 @@ shader_t *shader_console; #endif extern cvar_t con_ocranaleds; extern cvar_t gl_blend2d; +extern cvar_t scr_conalpha; qbyte *draw_chars; // 8*8 graphic characters mpic_t *draw_disc; @@ -1881,14 +1882,26 @@ void GLDraw_ConsoleBackground (int lines) { // char ver[80]; // int x, i; - int y; + float a; + extern qboolean scr_con_forcedraw; - y = (vid.height * 3) >> 2; conback->width = vid.conwidth; conback->height = vid.conheight; + + if (scr_con_forcedraw) + { + a = 1; // console background is necessary + } + else + { + if (scr_conalpha.value <= 0) + return; + + a = scr_conalpha.value; + } + if (scr_chatmode == 2) { - y=0; conback->height>>=1; conback->width>>=1; } @@ -1897,20 +1910,20 @@ void GLDraw_ConsoleBackground (int lines) if (shader_console) { currententity = &r_worldentity; - GLDraw_ShaderPic(0, lines - conback->height, vid.width, vid.height, shader_console, 1, 1, 1, (1.2*lines)/y); + GLDraw_ShaderPic(0, lines - conback->height, vid.width, vid.height, shader_console, 1, 1, 1, a); qglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); return; } } #endif - if (lines > y) + if (a >= 1) { qglColor3f (1,1,1); GLDraw_Pic(0, lines-conback->height, conback); } else { - GLDraw_AlphaPic (0, lines - conback->height, conback, (float)(1.2 * lines)/y); + GLDraw_AlphaPic (0, lines - conback->height, conback, a); } } diff --git a/engine/sw/d_part.c b/engine/sw/d_part.c index c386c794c..88954a8ce 100644 --- a/engine/sw/d_part.c +++ b/engine/sw/d_part.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "d_local.h" //Spike: Particles are depth sorted. So why depth write? They are the last to be drawn anyway. - +#define PARTICLEFACTOR 0x8000 // Change DP_Partfac in ASM to match this /* ============== @@ -87,7 +87,7 @@ void D_DrawParticle (particle_t *pparticle) pz = d_pzbuffer + (d_zwidth * v) + u; pdest = d_viewbuffer + d_scantable[v] + u; - izi = (int)(zi * 0x8000); + izi = (int)(zi * PARTICLEFACTOR); pix = izi >> d_pix_shift; pix *= pparticle->scale; @@ -244,9 +244,9 @@ void D_DrawParticle16 (particle_t *pparticle) } pz = d_pzbuffer + (d_zwidth * v) + u; - izi = (int)(zi * 0x8000); + izi = (int)(zi * PARTICLEFACTOR); - pix = ((int)(izi*pparticle->scale)) >> d_pix_shift; + pix = ((int)(izi*pparticle->scale)); if (pix < d_pix_min) pix = d_pix_min; @@ -319,7 +319,7 @@ void D_DrawParticle32 (particle_t *pparticle) } pz = d_pzbuffer + (d_zwidth * v) + u; - izi = (int)(zi * 0x8000); + izi = (int)(zi * PARTICLEFACTOR); pix = ((int)(izi*pparticle->scale)) >> d_pix_shift; @@ -419,7 +419,7 @@ void D_DrawParticleTrans (particle_t *pparticle, blendmode_t blendmode) } pz = d_pzbuffer + (d_zwidth * v) + u; - izi = (int)(zi * 0x8000); + izi = (int)(zi * PARTICLEFACTOR); pix = ((int)(izi*pparticle->scale)) >> d_pix_shift; diff --git a/engine/sw/d_parta.s b/engine/sw/d_parta.s index d694f5dbe..ce3f7c1e0 100644 --- a/engine/sw/d_parta.s +++ b/engine/sw/d_parta.s @@ -134,7 +134,7 @@ C(D_DrawParticle): fxch %st(1) // u | v | 1/z fadds float_point5 // u | v | 1/z fxch %st(2) // 1/z | v | u - fmuls DP_32768 // 1/z * 0x8000 | v | u + fmuls DP_Partfac // 1/z * 0x8000 | v | u fxch %st(2) // u | v | 1/z * 0x8000 // FIXME: use Terje's fp->int trick here? diff --git a/engine/sw/d_varsa.s b/engine/sw/d_varsa.s index 537c6b42c..a370c4847 100644 --- a/engine/sw/d_varsa.s +++ b/engine/sw/d_varsa.s @@ -146,11 +146,11 @@ entryvec_table_16: .long 0, Entry2_16, Entry3_16, Entry4_16 //------------------------------------------------------- // local variables for d_parta.s //------------------------------------------------------- -.globl DP_Count, DP_u, DP_v, DP_32768, DP_Color, DP_Pix, DP_EntryTable +.globl DP_Count, DP_u, DP_v, DP_Partfac, DP_Color, DP_Pix, DP_EntryTable DP_Count: .long 0 DP_u: .long 0 DP_v: .long 0 -DP_32768: .single 32768.0 +DP_Partfac: .single 32768.0 DP_Color: .long 0 DP_Pix: .long 0 diff --git a/engine/sw/sw_draw.c b/engine/sw/sw_draw.c index eeb726f82..90fb10e71 100644 --- a/engine/sw/sw_draw.c +++ b/engine/sw/sw_draw.c @@ -32,6 +32,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern unsigned int *d_8to32table; extern cvar_t con_ocranaleds; +extern cvar_t scr_conalpha; +extern qboolean scr_con_forcedraw; typedef struct { vrect_t rect; @@ -2016,6 +2018,9 @@ void SWDraw_ConsoleBackground (int lines) char ver[100]; static char saveback[320*8]; + if (!scr_con_forcedraw && scr_conalpha.value <= 0) + return; + conback = (mpic_t *)SWDraw_SafeCachePic ("gfx/conback.lmp"); if (!conback) conback = (mpic_t *)SWDraw_SafeCachePic("pics/conback.pcx"); @@ -2054,30 +2059,56 @@ void SWDraw_ConsoleBackground (int lines) { dest = vid.conbuffer; - for (y=0 ; ydata + v*320; - if (vid.conwidth == 320) - memcpy (dest, src, vid.conwidth); - else + for (y=0 ; ydata + v*320; f = 0; fstep = 320*0x10000/vid.conwidth; for (x=0 ; x>16]; + dest[x] = Trans(dest[x], src[f>>16]); f += fstep; - dest[x+1] = src[f>>16]; + dest[x+1] = Trans(dest[x+1], src[f>>16]); f += fstep; - dest[x+2] = src[f>>16]; + dest[x+2] = Trans(dest[x+2], src[f>>16]); f += fstep; - dest[x+3] = src[f>>16]; + dest[x+3] = Trans(dest[x+3], src[f>>16]); f += fstep; } } } + else + { + for (y=0 ; ydata + v*320; + if (vid.conwidth == 320) + memcpy (dest, src, vid.conwidth); + else + { + f = 0; + fstep = 320*0x10000/vid.conwidth; + for (x=0 ; x>16]; + f += fstep; + dest[x+1] = src[f>>16]; + f += fstep; + dest[x+2] = src[f>>16]; + f += fstep; + dest[x+3] = src[f>>16]; + f += fstep; + } + } + } + } } else if (r_pixbytes == 2) { @@ -2114,8 +2145,11 @@ void SWDraw_ConsoleBackground (int lines) extern cvar_t d_smooth; unsigned int *p24dest; unsigned char *pal = (qbyte *)d_8to32table; - int alpha = ((float)(lines)/((vid.height * 3) >> 2))*255; - if (alpha > 255) alpha = 255; + int alpha; + if (scr_con_forcedraw) + alpha = 255; + else + alpha = bound(0, scr_conalpha.value*255, 255); p24dest = (unsigned int *)vid.conbuffer; dest = (unsigned char *)vid.conbuffer;