From 7e078c7f9c8ab27af92ff268f49bac070c9ff617 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 28 Jan 2012 20:45:14 +0900 Subject: [PATCH] Revamp cshifts and implement in glsl. The renderer should now be free of any direct access to client code. Even 3d rendering is now done via a function pointer. The cshift code is done as a 2d screen function. --- include/QF/draw.h | 4 + include/QF/screen.h | 3 +- include/QF/vid.h | 1 + include/clview.h | 2 - libs/video/renderer/gl/gl_draw.c | 22 ++++++ libs/video/renderer/gl/gl_rmain.c | 4 +- libs/video/renderer/gl/gl_screen.c | 23 +----- libs/video/renderer/glsl/glsl_draw.c | 16 +++- libs/video/renderer/glsl/glsl_screen.c | 5 +- libs/video/renderer/sw/draw.c | 27 +++++++ libs/video/renderer/sw/screen.c | 34 +-------- libs/video/renderer/sw/sw_rmain.c | 3 - libs/video/renderer/sw32/draw.c | 94 +++++++++++++++++++++++ libs/video/renderer/sw32/screen.c | 101 +------------------------ libs/video/renderer/sw32/sw32_rmain.c | 3 - nq/source/cl_screen.c | 17 ++++- nq/source/cl_view.c | 9 +-- qw/source/cl_screen.c | 18 ++++- qw/source/cl_view.c | 9 +-- 19 files changed, 215 insertions(+), 180 deletions(-) diff --git a/include/QF/draw.h b/include/QF/draw.h index f86c77063..11a95e084 100644 --- a/include/QF/draw.h +++ b/include/QF/draw.h @@ -157,6 +157,10 @@ void Draw_TextBox (int x, int y, int width, int lines, byte alpha); /** Darken the screen. */ void Draw_FadeScreen (void); + +/** Shift the screen colors. +*/ +void Draw_BlendScreen (quat_t color); //@} /** \defgroup video_renderer_draw_qpic QPic functions diff --git a/include/QF/screen.h b/include/QF/screen.h index 3853cdb1a..1fc25e127 100644 --- a/include/QF/screen.h +++ b/include/QF/screen.h @@ -37,7 +37,8 @@ void SCR_Init (void); typedef void (*SCR_Func)(void); // scr_funcs is a null terminated array -void SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs); +void SCR_UpdateScreen (double realtime, SCR_Func scr_3dfunc, + SCR_Func *scr_funcs); void SCR_UpdateWholeScreen (void); void SCR_SizeUp (void); diff --git a/include/QF/vid.h b/include/QF/vid.h index 257cbcfe3..882c75ec5 100644 --- a/include/QF/vid.h +++ b/include/QF/vid.h @@ -63,6 +63,7 @@ typedef struct { int numpages; qboolean recalc_refdef; // if true, recalc vid-based stuff qboolean cshift_changed; + quat_t cshift_color; void *conbuffer; int conrowbytes; unsigned int conwidth; diff --git a/include/clview.h b/include/clview.h index 72027157c..952b71652 100644 --- a/include/clview.h +++ b/include/clview.h @@ -51,6 +51,4 @@ void V_Register (void); void V_SetContentsColor (int contents); void V_CalcBlend (void); -extern float v_blend[4]; - #endif // __clview_h_ diff --git a/libs/video/renderer/gl/gl_draw.c b/libs/video/renderer/gl/gl_draw.c index ce812e452..4902a9ad7 100644 --- a/libs/video/renderer/gl/gl_draw.c +++ b/libs/video/renderer/gl/gl_draw.c @@ -910,3 +910,25 @@ GL_FlushText (void) flush_text (); } } + +void +Draw_BlendScreen (quat_t color) +{ + if (!color[3]) + return; + + qfglDisable (GL_TEXTURE_2D); + + qfglBegin (GL_QUADS); + + qfglColor4fv (color); + qfglVertex2f (0, 0); + qfglVertex2f (vid.conwidth, 0); + qfglVertex2f (vid.conwidth, vid.conheight); + qfglVertex2f (0, vid.conheight); + + qfglEnd (); + + qfglColor3ubv (color_white); + qfglEnable (GL_TEXTURE_2D); +} diff --git a/libs/video/renderer/gl/gl_rmain.c b/libs/video/renderer/gl/gl_rmain.c index 1f2d0be01..69062d40c 100644 --- a/libs/video/renderer/gl/gl_rmain.c +++ b/libs/video/renderer/gl/gl_rmain.c @@ -65,7 +65,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "r_dynamic.h" #include "r_local.h" #include "varrays.h" -#include "clview.h" //FIXME entity_t r_worldentity; @@ -403,8 +402,6 @@ R_SetupFrame (void) // current viewleaf r_viewleaf = Mod_PointInLeaf (r_origin, r_worldentity.model); - V_SetContentsColor (r_viewleaf->contents); - r_cache_thrash = false; c_brush_polys = 0; @@ -947,6 +944,7 @@ R_RenderViewFishEye (void) VISIBLE void R_ClearState (void) { + r_worldentity.model = 0; R_ClearEfrags (); R_ClearDlights (); R_ClearParticles (); diff --git a/libs/video/renderer/gl/gl_screen.c b/libs/video/renderer/gl/gl_screen.c index 6a57193ad..d5ffb388c 100644 --- a/libs/video/renderer/gl/gl_screen.c +++ b/libs/video/renderer/gl/gl_screen.c @@ -61,7 +61,6 @@ static __attribute__ ((used)) const char rcsid[] = "$Id$"; #include "r_local.h" #include "r_screen.h" #include "sbar.h" -#include "clview.h" //FIXME /* SCREEN SHOTS */ @@ -202,7 +201,7 @@ SCR_TileClear (void) needs almost the entire 256k of stack space! */ VISIBLE void -SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs) +SCR_UpdateScreen (double realtime, SCR_Func scr_3dfunc, SCR_Func *scr_funcs) { double time1 = 0, time2; static int begun = 0; @@ -240,30 +239,12 @@ SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs) SCR_CalcRefdef (); // do 3D refresh drawing, and then update the screen - V_RenderView (); + scr_3dfunc (); SCR_SetUpToDrawConsole (); GL_Set2D (); GL_DrawReset (); - // also makes polyblend apply to whole screen - if (v_blend[3]) { - qfglDisable (GL_TEXTURE_2D); - - qfglBegin (GL_QUADS); - - qfglColor4fv (v_blend); - qfglVertex2f (0, 0); - qfglVertex2f (vid.width, 0); - qfglVertex2f (vid.width, vid.height); - qfglVertex2f (0, vid.height); - - qfglEnd (); - - qfglColor3ubv (color_white); - qfglEnable (GL_TEXTURE_2D); - } - // draw any areas not covered by the refresh SCR_TileClear (); diff --git a/libs/video/renderer/glsl/glsl_draw.c b/libs/video/renderer/glsl/glsl_draw.c index 20d9a4d92..1865cff61 100644 --- a/libs/video/renderer/glsl/glsl_draw.c +++ b/libs/video/renderer/glsl/glsl_draw.c @@ -692,13 +692,19 @@ Draw_Fill (int x, int y, int w, int h, int c) draw_pic (x, y, w, h, white_pic, 0, 0, 8, 8, color); } +static inline void +draw_blendscreen (quat_t color) +{ + draw_pic (0, 0, vid.conwidth, vid.conheight, white_pic, 0, 0, 8, 8, color); +} + VISIBLE void Draw_FadeScreen (void) { static quat_t color = { 0, 0, 0, 0.7 }; GL_FlushText (); // Flush text that should be rendered before the menu - draw_pic (0, 0, vid.conwidth, vid.conheight, white_pic, 0, 0, 8, 8, color); + draw_blendscreen (color); } static void @@ -761,3 +767,11 @@ GL_FlushText (void) if (char_queue->size) flush_text (); } + +void +Draw_BlendScreen (quat_t color) +{ + if (!color[3]) + return; + draw_blendscreen (color); +} diff --git a/libs/video/renderer/glsl/glsl_screen.c b/libs/video/renderer/glsl/glsl_screen.c index 2194b3c6b..0a650f136 100644 --- a/libs/video/renderer/glsl/glsl_screen.c +++ b/libs/video/renderer/glsl/glsl_screen.c @@ -57,7 +57,6 @@ static __attribute__ ((used)) const char rcsid[] = "$Id$"; #include "QF/GLSL/qf_textures.h" #include "QF/GLSL/qf_vid.h" -#include "clview.h"//FIXME #include "gl_draw.h" #include "r_cvar.h" #include "r_dynamic.h" @@ -157,7 +156,7 @@ SCR_TileClear (void) } VISIBLE void -SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs) +SCR_UpdateScreen (double realtime, SCR_Func scr_3dfunc, SCR_Func *scr_funcs) { static int begun = 0; @@ -187,7 +186,7 @@ SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs) if (vid.recalc_refdef) SCR_CalcRefdef (); - V_RenderView (); // FIXME (scr_3dfuncs?) + scr_3dfunc (); SCR_SetUpToDrawConsole (); GL_Set2D (); diff --git a/libs/video/renderer/sw/draw.c b/libs/video/renderer/sw/draw.c index 26ce2e545..3f886e972 100644 --- a/libs/video/renderer/sw/draw.c +++ b/libs/video/renderer/sw/draw.c @@ -645,3 +645,30 @@ Draw_FadeScreen (void) S_ExtraUpdate (); VID_LockBuffer (); } + +VISIBLE void +Draw_BlendScreen (quat_t color) +{ + int r, g, b, i; + byte *basepal, *newpal; + byte pal[768]; + basepal = vid.basepal; + newpal = pal; + + for (i = 0; i < 256; i++) { + r = basepal[0]; + g = basepal[1]; + b = basepal[2]; + basepal += 3; + + r += (int) (color[3] * (color[0] * 256 - r)); + g += (int) (color[3] * (color[1] * 256 - g)); + b += (int) (color[3] * (color[2] * 256 - b)); + + newpal[0] = gammatable[r]; + newpal[1] = gammatable[g]; + newpal[2] = gammatable[b]; + newpal += 3; + } + VID_ShiftPalette (pal); +} diff --git a/libs/video/renderer/sw/screen.c b/libs/video/renderer/sw/screen.c index bfe5b4db5..72024cc1c 100644 --- a/libs/video/renderer/sw/screen.c +++ b/libs/video/renderer/sw/screen.c @@ -55,34 +55,6 @@ static __attribute__ ((used)) const char rcsid[] = "$Id$"; #include "r_local.h" #include "r_screen.h" #include "sbar.h" -#include "clview.h" //FIXME - -static void -SCR_ApplyBlend (void) // Used to be V_UpdatePalette -{ - int r, g, b, i; - byte *basepal, *newpal; - byte pal[768]; - basepal = vid.basepal; - newpal = pal; - - for (i = 0; i < 256; i++) { - r = basepal[0]; - g = basepal[1]; - b = basepal[2]; - basepal += 3; - - r += (int) (v_blend[3] * (v_blend[0] * 256 - r)); - g += (int) (v_blend[3] * (v_blend[1] * 256 - g)); - b += (int) (v_blend[3] * (v_blend[2] * 256 - b)); - - newpal[0] = gammatable[r]; - newpal[1] = gammatable[g]; - newpal[2] = gammatable[b]; - newpal += 3; - } - VID_ShiftPalette (pal); -} /* SCREEN SHOTS */ @@ -221,7 +193,7 @@ SCR_ScreenShot_f (void) needs almost the entire 256k of stack space! */ void -SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs) +SCR_UpdateScreen (double realtime, SCR_Func scr_3dfunc, SCR_Func *scr_funcs) { vrect_t vrect; @@ -261,7 +233,7 @@ SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs) D_DisableBackBufferAccess (); // for adapters that can't stay mapped // in for linear writes all the time VID_LockBuffer (); - V_RenderView (); + scr_3dfunc (); VID_UnlockBuffer (); D_EnableBackBufferAccess (); // of all overlay stuff if drawing @@ -278,8 +250,6 @@ SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs) D_UpdateRects (pconupdate); } - SCR_ApplyBlend (); - // update one of three areas if (scr_copyeverything) { vrect.x = 0; diff --git a/libs/video/renderer/sw/sw_rmain.c b/libs/video/renderer/sw/sw_rmain.c index 5e547a68d..f44cdb48a 100644 --- a/libs/video/renderer/sw/sw_rmain.c +++ b/libs/video/renderer/sw/sw_rmain.c @@ -56,7 +56,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "r_cvar.h" #include "r_dynamic.h" #include "r_local.h" -#include "clview.h" //FIXME #ifdef PIC # undef USE_INTEL_ASM //XXX asm pic hack @@ -791,8 +790,6 @@ R_RenderView_ (void) if (r_dowarp) D_WarpScreen (); - V_SetContentsColor (r_viewleaf->contents); - if (r_timegraph->int_val) R_TimeGraph (); diff --git a/libs/video/renderer/sw32/draw.c b/libs/video/renderer/sw32/draw.c index ce84861cb..f6a6e23b9 100644 --- a/libs/video/renderer/sw32/draw.c +++ b/libs/video/renderer/sw32/draw.c @@ -1112,3 +1112,97 @@ Draw_FadeScreen (void) S_ExtraUpdate (); VID_LockBuffer (); } + +VISIBLE void +Draw_BlendScreen (quat_t color) +{ + int r, g, b, i; + byte *basepal, *newpal; + byte pal[768]; + + switch(r_pixbytes) { + case 1: + { + basepal = vid.basepal; + newpal = pal; + + for (i = 0; i < 256; i++) { + r = basepal[0]; + g = basepal[1]; + b = basepal[2]; + basepal += 3; + + r += (int) (color[3] * (color[0] * 256 - r)); + g += (int) (color[3] * (color[1] * 256 - g)); + b += (int) (color[3] * (color[2] * 256 -g)); + + newpal[0] = gammatable[r]; + newpal[1] = gammatable[g]; + newpal[2] = gammatable[b]; + newpal += 3; + } + VID_ShiftPalette (pal); + } + break; + case 2: + { + unsigned int g1, g2, x, y; + unsigned short rramp[32], gramp[64], bramp[32], *temp; + for (i = 0; i < 32; i++) { + r = i << 3; + g1 = i << 3; + g2 = g1 + 4; + b = i << 3; + + r += (int) (color[3] * (color[0] * 256 - r)); + g1 += (int) (color[3] * (color[1] - g1)); + g2 += (int) (color[3] * (color[1] - g2)); + b += (int) (color[3] * (color[2] - b)); + + rramp[i] = (gammatable[r] << 8) & 0xF800; + gramp[i*2+0] = (gammatable[g1] << 3) & 0x07E0; + gramp[i*2+1] = (gammatable[g2] << 3) & 0x07E0; + bramp[i] = (gammatable[b] >> 3) & 0x001F; + } + temp = vid.buffer; + for (y = 0;y < vid.height;y++, temp += (vid.rowbytes >> 1)) + for (x = 0;x < vid.width;x++) + temp[x] = rramp[(temp[x] & 0xF800) >> 11] + + gramp[(temp[x] & 0x07E0) >> 5] + bramp[temp[x] & 0x001F]; + } + break; + case 4: + { + unsigned int x, y; + byte ramp[256][4], *temp; + for (i = 0; i < 256; i++) { + r = i; + g = i; + b = i; + + r += (int) (color[3] * (color[0] * 256 - r)); + g += (int) (color[3] * (color[1] * 256 - g)); + b += (int) (color[3] * (color[2] * 256 - b)); + + ramp[i][0] = gammatable[r]; + ramp[i][1] = gammatable[g]; + ramp[i][2] = gammatable[b]; + ramp[i][3] = 0; + } + temp = vid.buffer; + for (y = 0;y < vid.height;y++, temp += vid.rowbytes) + { + for (x = 0;x < vid.width;x++) + { + temp[x*4+0] = ramp[temp[x*4+0]][0]; + temp[x*4+1] = ramp[temp[x*4+1]][1]; + temp[x*4+2] = ramp[temp[x*4+2]][2]; + temp[x*4+3] = 0; + } + } + } + break; + default: + Sys_Error("V_UpdatePalette: unsupported r_pixbytes %i", r_pixbytes); + } +} diff --git a/libs/video/renderer/sw32/screen.c b/libs/video/renderer/sw32/screen.c index 28fc6f064..8f767b82c 100644 --- a/libs/video/renderer/sw32/screen.c +++ b/libs/video/renderer/sw32/screen.c @@ -56,101 +56,6 @@ static __attribute__ ((used)) const char rcsid[] = "$Id$"; #include "r_local.h" #include "r_screen.h" #include "sbar.h" -#include "clview.h" - -static void -SCR_ApplyBlend (void) // Used to be V_UpdatePalette -{ - int r, g, b, i; - byte *basepal, *newpal; - byte pal[768]; - - switch(r_pixbytes) { - case 1: - { - basepal = vid.basepal; - newpal = pal; - - for (i = 0; i < 256; i++) { - r = basepal[0]; - g = basepal[1]; - b = basepal[2]; - basepal += 3; - - r += (int) (v_blend[3] * (v_blend[0] * 256 - r)); - g += (int) (v_blend[3] * (v_blend[1] * 256 - g)); - b += (int) (v_blend[3] * (v_blend[2] * 256 -g)); - - newpal[0] = gammatable[r]; - newpal[1] = gammatable[g]; - newpal[2] = gammatable[b]; - newpal += 3; - } - VID_ShiftPalette (pal); - } - break; - case 2: - { - unsigned int g1, g2, x, y; - unsigned short rramp[32], gramp[64], bramp[32], *temp; - for (i = 0; i < 32; i++) { - r = i << 3; - g1 = i << 3; - g2 = g1 + 4; - b = i << 3; - - r += (int) (v_blend[3] * (v_blend[0] * 256 - r)); - g1 += (int) (v_blend[3] * (v_blend[1] - g1)); - g2 += (int) (v_blend[3] * (v_blend[1] - g2)); - b += (int) (v_blend[3] * (v_blend[2] - b)); - - rramp[i] = (gammatable[r] << 8) & 0xF800; - gramp[i*2+0] = (gammatable[g1] << 3) & 0x07E0; - gramp[i*2+1] = (gammatable[g2] << 3) & 0x07E0; - bramp[i] = (gammatable[b] >> 3) & 0x001F; - } - temp = vid.buffer; - for (y = 0;y < vid.height;y++, temp += (vid.rowbytes >> 1)) - for (x = 0;x < vid.width;x++) - temp[x] = rramp[(temp[x] & 0xF800) >> 11] - + gramp[(temp[x] & 0x07E0) >> 5] + bramp[temp[x] & 0x001F]; - } - break; - case 4: - { - unsigned int x, y; - byte ramp[256][4], *temp; - for (i = 0; i < 256; i++) { - r = i; - g = i; - b = i; - - r += (int) (v_blend[3] * (v_blend[0] * 256 - r)); - g += (int) (v_blend[3] * (v_blend[1] * 256 - g)); - b += (int) (v_blend[3] * (v_blend[2] * 256 - b)); - - ramp[i][0] = gammatable[r]; - ramp[i][1] = gammatable[g]; - ramp[i][2] = gammatable[b]; - ramp[i][3] = 0; - } - temp = vid.buffer; - for (y = 0;y < vid.height;y++, temp += vid.rowbytes) - { - for (x = 0;x < vid.width;x++) - { - temp[x*4+0] = ramp[temp[x*4+0]][0]; - temp[x*4+1] = ramp[temp[x*4+1]][1]; - temp[x*4+2] = ramp[temp[x*4+2]][2]; - temp[x*4+3] = 0; - } - } - } - break; - default: - Sys_Error("V_UpdatePalette: unsupported r_pixbytes %i", r_pixbytes); - } -} /* SCREEN SHOTS */ @@ -242,7 +147,7 @@ SCR_ScreenShot_f (void) needs almost the entire 256k of stack space! */ VISIBLE void -SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs) +SCR_UpdateScreen (double realtime, SCR_Func scr_3dfunc, SCR_Func *scr_funcs) { vrect_t vrect; @@ -282,7 +187,7 @@ SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs) D_DisableBackBufferAccess (); // for adapters that can't stay mapped // in for linear writes all the time VID_LockBuffer (); - V_RenderView (); + scr_3dfunc (); VID_UnlockBuffer (); D_EnableBackBufferAccess (); // of all overlay stuff if drawing @@ -299,8 +204,6 @@ SCR_UpdateScreen (double realtime, SCR_Func *scr_funcs) D_UpdateRects (pconupdate); } - SCR_ApplyBlend (); - // update one of three areas if (scr_copyeverything) { vrect.x = 0; diff --git a/libs/video/renderer/sw32/sw32_rmain.c b/libs/video/renderer/sw32/sw32_rmain.c index 25029b9dc..522ede92f 100644 --- a/libs/video/renderer/sw32/sw32_rmain.c +++ b/libs/video/renderer/sw32/sw32_rmain.c @@ -53,7 +53,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "r_cvar.h" #include "r_dynamic.h" #include "r_local.h" -#include "clview.h" //define PASSAGES @@ -807,8 +806,6 @@ R_RenderView_ (void) if (r_dowarp) D_WarpScreen (); - V_SetContentsColor (r_viewleaf->contents); - if (r_timegraph->int_val) R_TimeGraph (); diff --git a/nq/source/cl_screen.c b/nq/source/cl_screen.c index 90d257bce..31ce22a74 100644 --- a/nq/source/cl_screen.c +++ b/nq/source/cl_screen.c @@ -76,6 +76,20 @@ SCR_DrawLoading (void) (vid.conheight - 48 - pic->height) / 2, pic); } +static void +SCR_CShift (void) +{ + mleaf_t *leaf; + int contents = CONTENTS_EMPTY; + + if (cls.signon != SIGNONS && cl.worldmodel) { + leaf = Mod_PointInLeaf (r_refdef.vieworg, cl.worldmodel); + contents = leaf->contents; + } + V_SetContentsColor (contents); + Draw_BlendScreen (vid.cshift_color); +} + static SCR_Func scr_funcs_normal[] = { Draw_Crosshair, SCR_DrawRam, @@ -86,6 +100,7 @@ static SCR_Func scr_funcs_normal[] = { Sbar_Draw, Con_DrawConsole, SCR_DrawLoading, + SCR_CShift, 0 }; @@ -118,5 +133,5 @@ CL_UpdateScreen (double realtime) cl_wateralpha = r_wateralpha->value; V_PrepBlend (); - SCR_UpdateScreen (realtime, scr_funcs[index]); + SCR_UpdateScreen (realtime, V_RenderView, scr_funcs[index]); } diff --git a/nq/source/cl_view.c b/nq/source/cl_view.c index cfb8fa43b..1f1128090 100644 --- a/nq/source/cl_view.c +++ b/nq/source/cl_view.c @@ -81,7 +81,6 @@ cvar_t *v_ipitch_level; cvar_t *v_idlescale; float v_dmg_time, v_dmg_roll, v_dmg_pitch; -float v_blend[4]; cshift_t cshift_empty = { {130, 80, 50}, 0}; @@ -390,10 +389,10 @@ V_CalcBlend (void) b *= a2; } - v_blend[0] = min (r, 255.0) / 255.0; - v_blend[1] = min (g, 255.0) / 255.0; - v_blend[2] = min (b, 255.0) / 255.0; - v_blend[3] = bound (0.0, a, 1.0); + vid.cshift_color[0] = min (r, 255.0) / 255.0; + vid.cshift_color[1] = min (g, 255.0) / 255.0; + vid.cshift_color[2] = min (b, 255.0) / 255.0; + vid.cshift_color[3] = bound (0.0, a, 1.0); } void diff --git a/qw/source/cl_screen.c b/qw/source/cl_screen.c index 09897c4e8..cb3a5747d 100644 --- a/qw/source/cl_screen.c +++ b/qw/source/cl_screen.c @@ -53,6 +53,7 @@ static __attribute__ ((used)) const char rcsid[] = #include "cl_parse.h" #include "client.h" +#include "clview.h" #include "compat.h" #include "r_local.h" #include "r_cvar.h" @@ -71,6 +72,20 @@ SCR_DrawNet (void) Draw_Pic (scr_vrect.x + 64, scr_vrect.y, scr_net); } +static void +SCR_CShift (void) +{ + mleaf_t *leaf; + int contents = CONTENTS_EMPTY; + + if (r_active && cl.worldmodel) { + leaf = Mod_PointInLeaf (r_refdef.vieworg, cl.worldmodel); + contents = leaf->contents; + } + V_SetContentsColor (contents); + Draw_BlendScreen (vid.cshift_color); +} + static SCR_Func scr_funcs_normal[] = { Draw_Crosshair, SCR_DrawRam, @@ -81,6 +96,7 @@ static SCR_Func scr_funcs_normal[] = { Sbar_DrawCenterPrint, Sbar_Draw, Con_DrawConsole, + SCR_CShift, 0 }; @@ -119,7 +135,7 @@ CL_UpdateScreen (double realtime) } V_PrepBlend (); - SCR_UpdateScreen (realtime, scr_funcs[index]); + SCR_UpdateScreen (realtime, V_RenderView, scr_funcs[index]); } void diff --git a/qw/source/cl_view.c b/qw/source/cl_view.c index 1908311bf..53c5ccb48 100644 --- a/qw/source/cl_view.c +++ b/qw/source/cl_view.c @@ -81,7 +81,6 @@ cvar_t *v_ipitch_level; cvar_t *v_idlescale; float v_dmg_time, v_dmg_roll, v_dmg_pitch; -float v_blend[4]; frame_t *view_frame; @@ -427,10 +426,10 @@ V_CalcBlend (void) b *= a2; } - v_blend[0] = min (r, 255.0) / 255.0; - v_blend[1] = min (g, 255.0) / 255.0; - v_blend[2] = min (b, 255.0) / 255.0; - v_blend[3] = bound (0.0, a, 1.0); + vid.cshift_color[0] = min (r, 255.0) / 255.0; + vid.cshift_color[1] = min (g, 255.0) / 255.0; + vid.cshift_color[2] = min (b, 255.0) / 255.0; + vid.cshift_color[3] = bound (0.0, a, 1.0); } void