diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 64826e799..363dd01f6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -905,6 +905,7 @@ add_executable( zdoom WIN32 fragglescript/t_cmd.cpp resources/colormaps.cpp resources/voxels.cpp + resources/renderstyle.cpp autozend.cpp ) diff --git a/src/actor.h b/src/actor.h index f41ec986b..2d148509b 100644 --- a/src/actor.h +++ b/src/actor.h @@ -37,7 +37,7 @@ #include "doomdef.h" #include "textures/textures.h" -#include "r_blend.h" +#include "resources/renderstyle.h" #include "s_sound.h" #include "memarena.h" diff --git a/src/d_main.cpp b/src/d_main.cpp index e59ebe6f6..070fc9167 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -765,7 +765,7 @@ void D_Display () } if (!automapactive || viewactive) { - R_RefreshViewBorder (); + V_RefreshViewBorder (); } if (hud_althud && viewheight == SCREENHEIGHT && screenblocks > 10) diff --git a/src/decallib.h b/src/decallib.h index 70804b0e5..a67aab44d 100644 --- a/src/decallib.h +++ b/src/decallib.h @@ -37,7 +37,7 @@ #include #include "doomtype.h" -#include "r_blend.h" +#include "resources/renderstyle.h" #include "textures/textures.h" class FScanner; diff --git a/src/doomstat.cpp b/src/doomstat.cpp index cd93ac18f..27c50b81e 100644 --- a/src/doomstat.cpp +++ b/src/doomstat.cpp @@ -67,3 +67,5 @@ int NextSkill = -1; int SinglePlayerClass[MAXPLAYERS]; bool ToggleFullscreen; +int BorderTopRefresh; + diff --git a/src/g_shared/sbarinfo.cpp b/src/g_shared/sbarinfo.cpp index c469bb736..1d8ffa8de 100644 --- a/src/g_shared/sbarinfo.cpp +++ b/src/g_shared/sbarinfo.cpp @@ -993,7 +993,7 @@ public: if(script->completeBorder) //Fill the statusbar with the border before we draw. { FTexture *b = TexMan[gameinfo.border->b]; - R_DrawBorder(viewwindowx, viewwindowy + viewheight + b->GetHeight(), viewwindowx + viewwidth, SCREENHEIGHT); + V_DrawBorder(viewwindowx, viewwindowy + viewheight + b->GetHeight(), viewwindowx + viewwidth, SCREENHEIGHT); if(screenblocks == 10) screen->FlatFill(viewwindowx, viewwindowy + viewheight, viewwindowx + viewwidth, viewwindowy + viewheight + b->GetHeight(), b, true); } diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index 0a0817a3f..4f1edfe1f 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -1053,8 +1053,8 @@ void DBaseStatusBar::RefreshBackground () const y = x == ST_X ? ST_Y : ::ST_Y; x2 = !(ratio & 3) || !Scaled ? ST_X+HorizontalResolution : SCREENWIDTH - (SCREENWIDTH*(48-BaseRatioSizes[ratio][3])+48*2-1)/(48*2); - R_DrawBorder (0, y, x, SCREENHEIGHT); - R_DrawBorder (x2, y, SCREENWIDTH, SCREENHEIGHT); + V_DrawBorder (0, y, x, SCREENHEIGHT); + V_DrawBorder (x2, y, SCREENWIDTH, SCREENHEIGHT); if (setblocks >= 10) { diff --git a/src/r_bsp.h b/src/r_bsp.h index 2cbdb2334..867bb3fcf 100644 --- a/src/r_bsp.h +++ b/src/r_bsp.h @@ -80,7 +80,6 @@ EXTERN_CVAR (Bool, r_drawflat) // [RH] Don't texture segs? // BSP? void R_ClearClipSegs (short left, short right); void R_ClearDrawSegs (); -void R_BuildPolyBSP(subsector_t *sub); void R_RenderBSPNode (void *node); // killough 4/13/98: fake floors/ceilings for deep water / fake ceilings: diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 3103772e7..42845bdf9 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -125,65 +125,6 @@ BYTE shadetables[NUMCOLORMAPS*16*256]; FDynamicColormap ShadeFakeColormap[16]; BYTE identitymap[256]; -// Convert legacy render styles to flexible render styles. - -// Apple's GCC 4.0.1 apparently wants to initialize the AsDWORD member of FRenderStyle -// rather than the struct before it, which goes against the standard. -#ifndef __APPLE__ -FRenderStyle LegacyRenderStyles[STYLE_Count] = -{ - /* STYLE_None */ {{ STYLEOP_None, STYLEALPHA_Zero, STYLEALPHA_Zero, 0 }}, - /* STYLE_Normal */ {{ STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_Alpha1 }}, - /* STYLE_Fuzzy */ {{ STYLEOP_Fuzz, STYLEALPHA_Src, STYLEALPHA_InvSrc, 0 }}, - /* STYLE_SoulTrans */ {{ STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_TransSoulsAlpha }}, - /* STYLE_OptFuzzy */ {{ STYLEOP_FuzzOrAdd, STYLEALPHA_Src, STYLEALPHA_InvSrc, 0 }}, - /* STYLE_Stencil */ {{ STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_Alpha1 | STYLEF_ColorIsFixed }}, - /* STYLE_Translucent */ {{ STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, 0 }}, - /* STYLE_Add */ {{ STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_One, 0 }}, - /* STYLE_Shaded */ {{ STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_RedIsAlpha | STYLEF_ColorIsFixed }}, -/* STYLE_TranslucentStencil */{{ STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_ColorIsFixed }}, - /* STYLE_Shadow */{{ STYLEOP_Shadow, 0, 0, 0 }}, -}; -#else -FRenderStyle LegacyRenderStyles[STYLE_Count]; - -static const BYTE Styles[STYLE_Count * 4] = -{ - STYLEOP_None, STYLEALPHA_Zero, STYLEALPHA_Zero, 0, - STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_Alpha1, - STYLEOP_Fuzz, STYLEALPHA_Src, STYLEALPHA_InvSrc, 0, - STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_TransSoulsAlpha, - STYLEOP_FuzzOrAdd, STYLEALPHA_Src, STYLEALPHA_InvSrc, 0, - STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_Alpha1 | STYLEF_ColorIsFixed, - STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, 0, - STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_One, 0, - STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_RedIsAlpha | STYLEF_ColorIsFixed, - STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_ColorIsFixed, - STYLEOP_Shadow, 0, 0, 0 -}; - -static struct LegacyInit -{ - LegacyInit() - { - for (int i = 0; i < STYLE_Count; ++i) - { - LegacyRenderStyles[i].BlendOp = Styles[i*4]; - LegacyRenderStyles[i].SrcAlpha = Styles[i*4+1]; - LegacyRenderStyles[i].DestAlpha = Styles[i*4+2]; - LegacyRenderStyles[i].Flags = Styles[i*4+3]; - } - } -} DoLegacyInit; - -#endif - -FArchive &operator<< (FArchive &arc, FRenderStyle &style) -{ - arc << style.BlendOp << style.SrcAlpha << style.DestAlpha << style.Flags; - return arc; -} - EXTERN_CVAR (Int, r_columnmethod) /************************************/ @@ -2020,29 +1961,6 @@ void tmvline4_revsubclamp () } -void R_DrawBorder (int x1, int y1, int x2, int y2) -{ - FTextureID picnum; - - if (level.info != NULL && level.info->bordertexture[0] != 0) - { - picnum = TexMan.CheckForTexture (level.info->bordertexture, FTexture::TEX_Flat); - } - else - { - picnum = TexMan.CheckForTexture (gameinfo.borderFlat, FTexture::TEX_Flat); - } - - if (picnum.isValid()) - { - screen->FlatFill (x1, y1, x2, y2, TexMan(picnum)); - } - else - { - screen->Clear (x1, y1, x2, y2, 0, 0); - } -} - //========================================================================== // // R_GetColumn @@ -2055,91 +1973,6 @@ const BYTE *R_GetColumn (FTexture *tex, int col) } -/* -================== -= -= R_DrawViewBorder -= -= Draws the border around the view for different size windows -================== -*/ - -int BorderNeedRefresh; - -void V_MarkRect (int x, int y, int width, int height); -void V_DrawFrame (int x, int y, int width, int height); - -void R_DrawViewBorder (void) -{ - // [RH] Redraw the status bar if SCREENWIDTH > status bar width. - // Will draw borders around itself, too. - if (SCREENWIDTH > 320) - { - SB_state = screen->GetPageCount (); - } - - if (viewwidth == SCREENWIDTH) - { - return; - } - - R_DrawBorder (0, 0, SCREENWIDTH, viewwindowy); - R_DrawBorder (0, viewwindowy, viewwindowx, viewheight + viewwindowy); - R_DrawBorder (viewwindowx + viewwidth, viewwindowy, SCREENWIDTH, viewheight + viewwindowy); - R_DrawBorder (0, viewwindowy + viewheight, SCREENWIDTH, ST_Y); - - V_DrawFrame (viewwindowx, viewwindowy, viewwidth, viewheight); - V_MarkRect (0, 0, SCREENWIDTH, ST_Y); -} - -/* -================== -= -= R_DrawTopBorder -= -= Draws the top border around the view for different size windows -================== -*/ - -int BorderTopRefresh; - -void R_DrawTopBorder () -{ - FTexture *p; - int offset; - - if (viewwidth == SCREENWIDTH) - return; - - offset = gameinfo.border->offset; - - if (viewwindowy < 34) - { - R_DrawBorder (0, 0, viewwindowx, 34); - R_DrawBorder (viewwindowx, 0, viewwindowx + viewwidth, viewwindowy); - R_DrawBorder (viewwindowx + viewwidth, 0, SCREENWIDTH, 34); - p = TexMan(gameinfo.border->t); - screen->FlatFill(viewwindowx, viewwindowy - p->GetHeight(), - viewwindowx + viewwidth, viewwindowy, p, true); - - p = TexMan(gameinfo.border->l); - screen->FlatFill(viewwindowx - p->GetWidth(), viewwindowy, - viewwindowx, 35, p, true); - p = TexMan(gameinfo.border->r); - screen->FlatFill(viewwindowx + viewwidth, viewwindowy, - viewwindowx + viewwidth + p->GetWidth(), 35, p, true); - - p = TexMan(gameinfo.border->tl); - screen->DrawTexture (p, viewwindowx - offset, viewwindowy - offset, TAG_DONE); - - p = TexMan(gameinfo.border->tr); - screen->DrawTexture (p, viewwindowx + viewwidth, viewwindowy - offset, TAG_DONE); - } - else - { - R_DrawBorder (0, 0, SCREENWIDTH, 34); - } -} // [RH] Initialize the column drawer pointers void R_InitColumnDrawers () { @@ -2175,8 +2008,8 @@ void R_InitColumnDrawers () // [RH] Choose column drawers in a single place EXTERN_CVAR (Int, r_drawfuzz) +EXTERN_CVAR (Bool, r_drawtrans) EXTERN_CVAR (Float, transsouls) -CVAR (Bool, r_drawtrans, true, 0) static FDynamicColormap *basecolormapsave; @@ -2323,18 +2156,6 @@ static bool R_SetBlendFunc (int op, fixed_t fglevel, fixed_t bglevel, int flags) } } -static fixed_t GetAlpha(int type, fixed_t alpha) -{ - switch (type) - { - case STYLEALPHA_Zero: return 0; - case STYLEALPHA_One: return FRACUNIT; - case STYLEALPHA_Src: return alpha; - case STYLEALPHA_InvSrc: return FRACUNIT - alpha; - default: return 0; - } -} - ESPSResult R_SetPatchStyle (FRenderStyle style, fixed_t alpha, int translation, DWORD color) { fixed_t fglevel, bglevel; @@ -2461,84 +2282,3 @@ bool R_GetTransMaskDrawers (fixed_t (**tmvline1)(), void (**tmvline4)()) return false; } -//========================================================================== -// -// FRenderStyle :: IsVisible -// -// Coupled with the given alpha, will this render style produce something -// visible on-screen? -// -//========================================================================== - -bool FRenderStyle::IsVisible(fixed_t alpha) const throw() -{ - if (BlendOp == STYLEOP_None) - { - return false; - } - if (BlendOp == STYLEOP_Add || BlendOp == STYLEOP_RevSub) - { - if (Flags & STYLEF_Alpha1) - { - alpha = FRACUNIT; - } - else - { - alpha = clamp(alpha, 0, FRACUNIT); - } - return GetAlpha(SrcAlpha, alpha) != 0 || GetAlpha(DestAlpha, alpha) != FRACUNIT; - } - // Treat anything else as visible. - return true; -} - - -//========================================================================== -// -// FRenderStyle :: CheckFuzz -// -// Adjusts settings based on r_drawfuzz CVAR -// -//========================================================================== - -void FRenderStyle::CheckFuzz() -{ - switch (BlendOp) - { - default: - return; - - case STYLEOP_FuzzOrAdd: - if (r_drawtrans && r_drawfuzz == 0) - { - BlendOp = STYLEOP_Add; - return; - } - break; - - case STYLEOP_FuzzOrSub: - if (r_drawtrans && r_drawfuzz == 0) - { - BlendOp = STYLEOP_Sub; - return; - } - break; - - case STYLEOP_FuzzOrRevSub: - if (r_drawtrans && r_drawfuzz == 0) - { - BlendOp = STYLEOP_RevSub; - return; - } - break; - } - - if (r_drawfuzz == 2) - { - BlendOp = STYLEOP_Shadow; - } - else - { - BlendOp = STYLEOP_Fuzz; - } -} diff --git a/src/r_draw.h b/src/r_draw.h index 8ff62d341..be254a62f 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -251,12 +251,6 @@ extern FDynamicColormap ShadeFakeColormap[16]; extern BYTE identitymap[256]; extern BYTE *dc_translation; - -// If the view size is not full screen, draws a border around it. -void R_DrawViewBorder (void); -void R_DrawTopBorder (void); -void R_DrawBorder (int x1, int y1, int x2, int y2); - // [RH] Added for muliresolution support void R_InitFuzzTable (int fuzzoff); diff --git a/src/r_main.cpp b/src/r_main.cpp index dda822fa2..172c0c773 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -1403,35 +1403,6 @@ void R_SetupFrame (AActor *actor) } } -//========================================================================== -// -// R_RefreshViewBorder -// -// Draws the border around the player view, if needed. -// -//========================================================================== - -void R_RefreshViewBorder () -{ - if (setblocks < 10) - { - if (BorderNeedRefresh) - { - BorderNeedRefresh--; - if (BorderTopRefresh) - { - BorderTopRefresh--; - } - R_DrawViewBorder(); - } - else if (BorderTopRefresh) - { - BorderTopRefresh--; - R_DrawTopBorder(); - } - } -} - //========================================================================== // // R_EnterMirror diff --git a/src/r_main.h b/src/r_main.h index 2259b0db9..8fda1f416 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -186,7 +186,6 @@ void R_SetViewAngle (); // Called by G_Drawer. void R_RenderActorView (AActor *actor, bool dontmaplines = false); -void R_RefreshViewBorder (); void R_SetupBuffer (); void R_RenderViewToCanvas (AActor *actor, DCanvas *canvas, int x, int y, int width, int height, bool dontmaplines = false); diff --git a/src/r_things.cpp b/src/r_things.cpp index 9876fe1d4..a464febaf 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -69,8 +69,8 @@ extern fixed_t globaluclip, globaldclip; #define BASEYCENTER (100) EXTERN_CVAR (Bool, st_scale) -CVAR (Int, r_drawfuzz, 1, CVAR_ARCHIVE) EXTERN_CVAR(Bool, r_shadercolormaps) +EXTERN_CVAR(Int, r_drawfuzz) // // Sprite rotation 0 is facing the viewer, diff --git a/src/resources/renderstyle.cpp b/src/resources/renderstyle.cpp new file mode 100644 index 000000000..4b1d9fed4 --- /dev/null +++ b/src/resources/renderstyle.cpp @@ -0,0 +1,195 @@ +/* +** r_data.cpp +** +**--------------------------------------------------------------------------- +** Copyright 2008-2011 Randy Heit +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + +#include "farchive.h" +#include "templates.h" +#include "renderstyle.h" +#include "c_cvars.h" + +CVAR (Bool, r_drawtrans, true, 0) +CVAR (Int, r_drawfuzz, 1, CVAR_ARCHIVE) + +// Convert legacy render styles to flexible render styles. + +// Apple's GCC 4.0.1 apparently wants to initialize the AsDWORD member of FRenderStyle +// rather than the struct before it, which goes against the standard. +#ifndef __APPLE__ +FRenderStyle LegacyRenderStyles[STYLE_Count] = +{ + /* STYLE_None */ {{ STYLEOP_None, STYLEALPHA_Zero, STYLEALPHA_Zero, 0 }}, + /* STYLE_Normal */ {{ STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_Alpha1 }}, + /* STYLE_Fuzzy */ {{ STYLEOP_Fuzz, STYLEALPHA_Src, STYLEALPHA_InvSrc, 0 }}, + /* STYLE_SoulTrans */ {{ STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_TransSoulsAlpha }}, + /* STYLE_OptFuzzy */ {{ STYLEOP_FuzzOrAdd, STYLEALPHA_Src, STYLEALPHA_InvSrc, 0 }}, + /* STYLE_Stencil */ {{ STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_Alpha1 | STYLEF_ColorIsFixed }}, + /* STYLE_Translucent */ {{ STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, 0 }}, + /* STYLE_Add */ {{ STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_One, 0 }}, + /* STYLE_Shaded */ {{ STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_RedIsAlpha | STYLEF_ColorIsFixed }}, +/* STYLE_TranslucentStencil */{{ STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_ColorIsFixed }}, + /* STYLE_Shadow */{{ STYLEOP_Shadow, 0, 0, 0 }}, +}; +#else +FRenderStyle LegacyRenderStyles[STYLE_Count]; + +static const BYTE Styles[STYLE_Count * 4] = +{ + STYLEOP_None, STYLEALPHA_Zero, STYLEALPHA_Zero, 0, + STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_Alpha1, + STYLEOP_Fuzz, STYLEALPHA_Src, STYLEALPHA_InvSrc, 0, + STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_TransSoulsAlpha, + STYLEOP_FuzzOrAdd, STYLEALPHA_Src, STYLEALPHA_InvSrc, 0, + STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_Alpha1 | STYLEF_ColorIsFixed, + STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, 0, + STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_One, 0, + STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_RedIsAlpha | STYLEF_ColorIsFixed, + STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_ColorIsFixed, + STYLEOP_Shadow, 0, 0, 0 +}; + +static struct LegacyInit +{ + LegacyInit() + { + for (int i = 0; i < STYLE_Count; ++i) + { + LegacyRenderStyles[i].BlendOp = Styles[i*4]; + LegacyRenderStyles[i].SrcAlpha = Styles[i*4+1]; + LegacyRenderStyles[i].DestAlpha = Styles[i*4+2]; + LegacyRenderStyles[i].Flags = Styles[i*4+3]; + } + } +} DoLegacyInit; + +#endif + +FArchive &operator<< (FArchive &arc, FRenderStyle &style) +{ + arc << style.BlendOp << style.SrcAlpha << style.DestAlpha << style.Flags; + return arc; +} + +//========================================================================== +// +// FRenderStyle :: IsVisible +// +// Coupled with the given alpha, will this render style produce something +// visible on-screen? +// +//========================================================================== + +bool FRenderStyle::IsVisible(fixed_t alpha) const throw() +{ + if (BlendOp == STYLEOP_None) + { + return false; + } + if (BlendOp == STYLEOP_Add || BlendOp == STYLEOP_RevSub) + { + if (Flags & STYLEF_Alpha1) + { + alpha = FRACUNIT; + } + else + { + alpha = clamp(alpha, 0, FRACUNIT); + } + return GetAlpha(SrcAlpha, alpha) != 0 || GetAlpha(DestAlpha, alpha) != FRACUNIT; + } + // Treat anything else as visible. + return true; +} + + +//========================================================================== +// +// FRenderStyle :: CheckFuzz +// +// Adjusts settings based on r_drawfuzz CVAR +// +//========================================================================== + +void FRenderStyle::CheckFuzz() +{ + switch (BlendOp) + { + default: + return; + + case STYLEOP_FuzzOrAdd: + if (r_drawtrans && r_drawfuzz == 0) + { + BlendOp = STYLEOP_Add; + return; + } + break; + + case STYLEOP_FuzzOrSub: + if (r_drawtrans && r_drawfuzz == 0) + { + BlendOp = STYLEOP_Sub; + return; + } + break; + + case STYLEOP_FuzzOrRevSub: + if (r_drawtrans && r_drawfuzz == 0) + { + BlendOp = STYLEOP_RevSub; + return; + } + break; + } + + if (r_drawfuzz == 2) + { + BlendOp = STYLEOP_Shadow; + } + else + { + BlendOp = STYLEOP_Fuzz; + } +} + +fixed_t GetAlpha(int type, fixed_t alpha) +{ + switch (type) + { + case STYLEALPHA_Zero: return 0; + case STYLEALPHA_One: return FRACUNIT; + case STYLEALPHA_Src: return alpha; + case STYLEALPHA_InvSrc: return FRACUNIT - alpha; + default: return 0; + } +} + diff --git a/src/r_blend.h b/src/resources/renderstyle.h similarity index 96% rename from src/r_blend.h rename to src/resources/renderstyle.h index f9fefc9d1..8133557d5 100644 --- a/src/r_blend.h +++ b/src/resources/renderstyle.h @@ -148,5 +148,6 @@ inline FRenderStyle &FRenderStyle::operator= (ERenderStyle legacy) class FArchive; FArchive &operator<< (FArchive &arc, FRenderStyle &style); +fixed_t GetAlpha(int type, fixed_t alpha); #endif diff --git a/src/v_draw.cpp b/src/v_draw.cpp index abbf82788..fd115a27f 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -46,6 +46,8 @@ #include "doomstat.h" #include "v_palette.h" #include "gi.h" +#include "g_level.h" +#include "st_stuff.h" #include "i_system.h" #include "i_video.h" @@ -66,6 +68,7 @@ int CleanXfac_1, CleanYfac_1, CleanWidth_1, CleanHeight_1; // FillSimplePoly uses this extern "C" short spanend[MAXHEIGHT]; +extern int setblocks; CVAR (Bool, hud_scale, false, CVAR_ARCHIVE); @@ -1384,4 +1387,143 @@ void V_DrawFrame (int left, int top, int width, int height) screen->DrawTexture (TexMan[border->tr], left+width, top-offset, TAG_DONE); screen->DrawTexture (TexMan[border->bl], left-offset, top+height, TAG_DONE); screen->DrawTexture (TexMan[border->br], left+width, top+height, TAG_DONE); -} \ No newline at end of file +} + +//========================================================================== +// +// +// +//========================================================================== + +void V_DrawBorder (int x1, int y1, int x2, int y2) +{ + FTextureID picnum; + + if (level.info != NULL && level.info->bordertexture[0] != 0) + { + picnum = TexMan.CheckForTexture (level.info->bordertexture, FTexture::TEX_Flat); + } + else + { + picnum = TexMan.CheckForTexture (gameinfo.borderFlat, FTexture::TEX_Flat); + } + + if (picnum.isValid()) + { + screen->FlatFill (x1, y1, x2, y2, TexMan(picnum)); + } + else + { + screen->Clear (x1, y1, x2, y2, 0, 0); + } +} + +//========================================================================== +// +// R_DrawViewBorder +// +// Draws the border around the view for different size windows +// +//========================================================================== + +int BorderNeedRefresh; + + +static void V_DrawViewBorder (void) +{ + // [RH] Redraw the status bar if SCREENWIDTH > status bar width. + // Will draw borders around itself, too. + if (SCREENWIDTH > 320) + { + SB_state = screen->GetPageCount (); + } + + if (viewwidth == SCREENWIDTH) + { + return; + } + + V_DrawBorder (0, 0, SCREENWIDTH, viewwindowy); + V_DrawBorder (0, viewwindowy, viewwindowx, viewheight + viewwindowy); + V_DrawBorder (viewwindowx + viewwidth, viewwindowy, SCREENWIDTH, viewheight + viewwindowy); + V_DrawBorder (0, viewwindowy + viewheight, SCREENWIDTH, ST_Y); + + V_DrawFrame (viewwindowx, viewwindowy, viewwidth, viewheight); + V_MarkRect (0, 0, SCREENWIDTH, ST_Y); +} + +//========================================================================== +// +// R_DrawTopBorder +// +// Draws the top border around the view for different size windows +// +//========================================================================== + +static void V_DrawTopBorder () +{ + FTexture *p; + int offset; + + if (viewwidth == SCREENWIDTH) + return; + + offset = gameinfo.border->offset; + + if (viewwindowy < 34) + { + V_DrawBorder (0, 0, viewwindowx, 34); + V_DrawBorder (viewwindowx, 0, viewwindowx + viewwidth, viewwindowy); + V_DrawBorder (viewwindowx + viewwidth, 0, SCREENWIDTH, 34); + p = TexMan(gameinfo.border->t); + screen->FlatFill(viewwindowx, viewwindowy - p->GetHeight(), + viewwindowx + viewwidth, viewwindowy, p, true); + + p = TexMan(gameinfo.border->l); + screen->FlatFill(viewwindowx - p->GetWidth(), viewwindowy, + viewwindowx, 35, p, true); + p = TexMan(gameinfo.border->r); + screen->FlatFill(viewwindowx + viewwidth, viewwindowy, + viewwindowx + viewwidth + p->GetWidth(), 35, p, true); + + p = TexMan(gameinfo.border->tl); + screen->DrawTexture (p, viewwindowx - offset, viewwindowy - offset, TAG_DONE); + + p = TexMan(gameinfo.border->tr); + screen->DrawTexture (p, viewwindowx + viewwidth, viewwindowy - offset, TAG_DONE); + } + else + { + V_DrawBorder (0, 0, SCREENWIDTH, 34); + } +} + +//========================================================================== +// +// R_RefreshViewBorder +// +// Draws the border around the player view, if needed. +// +//========================================================================== + +void V_RefreshViewBorder () +{ + if (setblocks < 10) + { + if (BorderNeedRefresh) + { + BorderNeedRefresh--; + if (BorderTopRefresh) + { + BorderTopRefresh--; + } + V_DrawViewBorder(); + } + else if (BorderTopRefresh) + { + BorderTopRefresh--; + V_DrawTopBorder(); + } + } +} + diff --git a/src/v_video.h b/src/v_video.h index b56a4d289..d3fbd8de2 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -38,7 +38,7 @@ #include "doomdef.h" #include "dobject.h" -#include "r_blend.h" +#include "resources/renderstyle.h" #include "c_cvars.h" extern int CleanWidth, CleanHeight, CleanXfac, CleanYfac; @@ -499,6 +499,11 @@ FString V_GetColorStringByName (const char *name); int V_GetColor (const DWORD *palette, const char *str); void V_DrawFrame (int left, int top, int width, int height); +// If the view size is not full screen, draws a border around it. +void V_DrawBorder (int x1, int y1, int x2, int y2); +void V_RefreshViewBorder (); + + #if defined(X86_ASM) || defined(X64_ASM) extern "C" void ASM_PatchPitch (void); #endif diff --git a/zdoom.vcproj b/zdoom.vcproj index a91713e29..fc39da840 100644 --- a/zdoom.vcproj +++ b/zdoom.vcproj @@ -2371,10 +2371,6 @@ RelativePath=".\src\r_3dfloors.h" > - - @@ -6636,6 +6632,10 @@ RelativePath=".\src\resources\colormaps.h" > + + @@ -6648,6 +6648,10 @@ RelativePath=".\src\resources\colormaps.cpp" > + +