diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h index 80cf49b644..9327579b8b 100644 --- a/src/gl/scene/gl_drawinfo.h +++ b/src/gl/scene/gl_drawinfo.h @@ -15,7 +15,5 @@ struct FDrawInfo : public HWDrawInfo { void DrawScene(int drawmode) override; void ProcessScene(bool toscreen = false); - void EndDrawScene(sector_t * viewsector); - void DrawEndScene2D(sector_t * viewsector); }; #endif diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 520c8b7920..e7fb11eabd 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -140,60 +140,6 @@ void FDrawInfo::DrawScene(int drawmode) RenderTranslucent(gl_RenderState); } -//----------------------------------------------------------------------------- -// -// Draws player sprites and color blend -// -//----------------------------------------------------------------------------- - - -void FDrawInfo::EndDrawScene(sector_t * viewsector) -{ - gl_RenderState.EnableFog(false); - - // [BB] HUD models need to be rendered here. - const bool renderHUDModel = IsHUDModelForPlayerAvailable( players[consoleplayer].camera->player ); - if ( renderHUDModel ) - { - // [BB] The HUD model should be drawn over everything else already drawn. - glClear(GL_DEPTH_BUFFER_BIT); - DrawPlayerSprites(true, gl_RenderState); - } - - glDisable(GL_STENCIL_TEST); - glViewport(screen->mScreenViewport.left, screen->mScreenViewport.top, screen->mScreenViewport.width, screen->mScreenViewport.height); - - // Restore standard rendering state - gl_RenderState.SetRenderStyle(STYLE_Translucent); - gl_RenderState.ResetColor(); - gl_RenderState.EnableTexture(true); - glDisable(GL_SCISSOR_TEST); -} - -void FDrawInfo::DrawEndScene2D(sector_t * viewsector) -{ - const bool renderHUDModel = IsHUDModelForPlayerAvailable(players[consoleplayer].camera->player); - auto vrmode = VRMode::GetVRMode(true); - - HWViewpointUniforms vp = VPUniforms; - vp.mViewMatrix.loadIdentity(); - vp.mProjectionMatrix = vrmode->GetHUDSpriteProjection(); - screen->mViewpoints->SetViewpoint(gl_RenderState, &vp); - glDisable(GL_DEPTH_TEST); - glDisable(GL_MULTISAMPLE); - - - DrawPlayerSprites(false, gl_RenderState); - - gl_RenderState.SetSoftLightLevel(-1); - - // Restore standard rendering state - gl_RenderState.SetRenderStyle(STYLE_Translucent); - gl_RenderState.ResetColor(); - gl_RenderState.EnableTexture(true); - glDisable(GL_SCISSOR_TEST); -} - //----------------------------------------------------------------------------- // // R_RenderView - renders one view - either the screen or a camera texture @@ -287,7 +233,7 @@ sector_t * FGLRenderer::RenderViewpoint (FRenderViewpoint &mainvp, AActor * came if (mainview) { PostProcess.Clock(); - if (toscreen) di->EndDrawScene(mainvp.sector); // do not call this for camera textures. + if (toscreen) di->EndDrawScene(mainvp.sector, gl_RenderState); // do not call this for camera textures. if (gl_RenderState.GetPassType() == GBUFFER_PASS) // Turn off ssao draw buffers { @@ -299,7 +245,7 @@ sector_t * FGLRenderer::RenderViewpoint (FRenderViewpoint &mainvp, AActor * came FGLDebug::PopGroup(); // MainView - PostProcessScene(cm, [&]() { di->DrawEndScene2D(mainvp.sector); }); + PostProcessScene(cm, [&]() { di->DrawEndScene2D(mainvp.sector, gl_RenderState); }); PostProcess.Unclock(); } di->EndDrawInfo(); diff --git a/src/hwrenderer/scene/hw_drawinfo.cpp b/src/hwrenderer/scene/hw_drawinfo.cpp index 752471d043..42c728c7eb 100644 --- a/src/hwrenderer/scene/hw_drawinfo.cpp +++ b/src/hwrenderer/scene/hw_drawinfo.cpp @@ -35,11 +35,13 @@ #include "hw_renderstate.h" #include "hw_drawinfo.h" #include "po_man.h" +#include "r_data/models/models.h" #include "hwrenderer/utility/hw_clock.h" #include "hwrenderer/utility/hw_cvars.h" #include "hwrenderer/data/hw_viewpointbuffer.h" #include "hwrenderer/data/flatvertices.h" #include "hwrenderer/dynlights/hw_lightbuffer.h" +#include "hwrenderer/utility/hw_vrmodes.h" #include "hw_clipper.h" EXTERN_CVAR(Float, r_visibility) @@ -590,3 +592,56 @@ void HWDrawInfo::RenderPortal(HWPortal *p, FRenderState &state, bool usestencil) } +//----------------------------------------------------------------------------- +// +// Draws player sprites and color blend +// +//----------------------------------------------------------------------------- + + +void HWDrawInfo::EndDrawScene(sector_t * viewsector, FRenderState &state) +{ + state.EnableFog(false); + + // [BB] HUD models need to be rendered here. + const bool renderHUDModel = IsHUDModelForPlayerAvailable(players[consoleplayer].camera->player); + if (renderHUDModel) + { + // [BB] The HUD model should be drawn over everything else already drawn. + state.Clear(CT_Depth); + DrawPlayerSprites(true, state); + } + + state.EnableStencil(false); + state.SetViewport(screen->mScreenViewport.left, screen->mScreenViewport.top, screen->mScreenViewport.width, screen->mScreenViewport.height); + + // Restore standard rendering state + state.SetRenderStyle(STYLE_Translucent); + state.ResetColor(); + state.EnableTexture(true); + state.SetScissor(0, 0, -1, -1); +} + +void HWDrawInfo::DrawEndScene2D(sector_t * viewsector, FRenderState &state) +{ + const bool renderHUDModel = IsHUDModelForPlayerAvailable(players[consoleplayer].camera->player); + auto vrmode = VRMode::GetVRMode(true); + + HWViewpointUniforms vp = VPUniforms; + vp.mViewMatrix.loadIdentity(); + vp.mProjectionMatrix = vrmode->GetHUDSpriteProjection(); + screen->mViewpoints->SetViewpoint(state, &vp); + state.EnableDepthTest(false); + state.EnableMultisampling(false); + + DrawPlayerSprites(false, state); + + state.SetSoftLightLevel(-1); + + // Restore standard rendering state + state.SetRenderStyle(STYLE_Translucent); + state.ResetColor(); + state.EnableTexture(true); + state.SetScissor(0, 0, -1, -1); +} + diff --git a/src/hwrenderer/scene/hw_drawinfo.h b/src/hwrenderer/scene/hw_drawinfo.h index 908225a24f..649fc69b7b 100644 --- a/src/hwrenderer/scene/hw_drawinfo.h +++ b/src/hwrenderer/scene/hw_drawinfo.h @@ -306,6 +306,8 @@ public: void RenderScene(FRenderState &state); void RenderTranslucent(FRenderState &state); void RenderPortal(HWPortal *p, FRenderState &state, bool usestencil); + void EndDrawScene(sector_t * viewsector, FRenderState &state); + void DrawEndScene2D(sector_t * viewsector, FRenderState &state); bool DoOneSectorUpper(subsector_t * subsec, float planez, area_t in_area); bool DoOneSectorLower(subsector_t * subsec, float planez, area_t in_area);