From 1765e270d1dd3c26a548852589fee951ffd4fbc4 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 11 Apr 2024 22:12:21 +0100 Subject: [PATCH] V_DrawCustomFadeScreen fallback behaviour for Legacy GL --- src/d_main.cpp | 11 +++++++++-- src/hardware/hw_draw.c | 27 +++++++++++++++++++++++++++ src/hardware/hw_main.h | 1 + src/v_video.cpp | 8 +++++++- 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index 87141c251..3b139029b 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -637,13 +637,17 @@ static bool D_Display(bool world) } // rhi: display the software framebuffer to the screen - if (rendermode == render_soft) + //if (rendermode == render_soft) { // TODO: THIS SHOULD IDEALLY BE IN REGULAR HUD CODE !! // (st_stuff.c ST_Drawer, also duplicated in k_podium.c) // Unfortunately this is the latest place we can do it // If we could immediately tint the GPU data a lot // of problems could be solved (including GL support) + // --- + // last minute toast edit: We need to run most of this so + // that the fallback GL behaviour activates at the right time + if (gamestate != GS_TITLESCREEN && G_GamestateUsesLevel() == true && lt_fade < 16) @@ -668,7 +672,10 @@ static bool D_Display(bool world) } } - VID_DisplaySoftwareScreen(); + if (rendermode == render_soft) + { + VID_DisplaySoftwareScreen(); + } } if (lastdraw) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index e4bd41f11..e8784a5c1 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -748,6 +748,33 @@ void HWR_EncoreInvertScreen(void) HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Invert|PF_NoDepthTest); } +void HWR_DrawCustomFadeScreen(UINT8 color, UINT8 strength) +{ + FOutVector v[4]; + FSurfaceInfo Surf; + + v[0].x = v[3].x = -1.0f; + v[2].x = v[1].x = 1.0f; + v[0].y = v[1].y = -1.0f; + v[2].y = v[3].y = 1.0f; + v[0].z = v[1].z = v[2].z = v[3].z = 1.0f; + + v[0].s = v[3].s = 0.0f; + v[2].s = v[1].s = 1.0f; + v[0].t = v[1].t = 1.0f; + v[2].t = v[3].t = 0.0f; + + Surf.PolyColor.rgba = V_GetColor(color).rgba; + + UINT16 workingstrength = (strength*12); + if (workingstrength > 0xFF) + Surf.PolyColor.s.alpha = 0xFF; + else + Surf.PolyColor.s.alpha = workingstrength; + + HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest); +} + // Very similar to HWR_DrawConsoleBack, except we draw from the middle(-ish) of the screen to the bottom. void HWR_DrawTutorialBack(UINT32 color, INT32 boxheight) { diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index a489c510c..2d5a530a7 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -34,6 +34,7 @@ void HWR_drawAMline(const fline_t *fl, INT32 color); void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength); void HWR_DrawConsoleBack(UINT32 color, INT32 height); void HWR_EncoreInvertScreen(void); +void HWR_DrawCustomFadeScreen(UINT8 color, UINT8 strength); void HWR_DrawTutorialBack(UINT32 color, INT32 boxheight); void HWR_RenderSkyboxView(player_t *player); void HWR_RenderPlayerView(void); diff --git a/src/v_video.cpp b/src/v_video.cpp index 4cc0d1990..dfab8889e 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -1602,7 +1602,13 @@ void V_DrawCustomFadeScreen(const char *lump, UINT8 strength) #ifdef HWRENDER if (rendermode != render_soft && rendermode != render_none) { - //HWR_DrawCustomFadeScreen(color, strength); + HWR_DrawCustomFadeScreen( + (strcmp(lump, "FADEMAP1") != 0 + ? 31 + : 0 + ), + strength + ); return; } #endif