From 70f9507f16990d0ee93d5db55e4470b5ed985429 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 28 Oct 2018 23:18:19 +0100 Subject: [PATCH] - moved RenderPortal, too. --- src/gl/scene/gl_drawinfo.cpp | 54 ---------------------------- src/gl/scene/gl_drawinfo.h | 2 -- src/gl/scene/gl_scene.cpp | 4 +-- src/hwrenderer/scene/hw_drawinfo.cpp | 22 ++++++++++++ src/hwrenderer/scene/hw_drawinfo.h | 2 +- src/hwrenderer/scene/hw_portal.cpp | 12 +++---- src/hwrenderer/scene/hw_portal.h | 6 ++-- 7 files changed, 34 insertions(+), 68 deletions(-) delete mode 100644 src/gl/scene/gl_drawinfo.cpp diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp deleted file mode 100644 index 90fc1d75e1..0000000000 --- a/src/gl/scene/gl_drawinfo.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// -//--------------------------------------------------------------------------- -// -// Copyright(C) 2002-2016 Christoph Oelckers -// All rights reserved. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see http://www.gnu.org/licenses/ -// -//-------------------------------------------------------------------------- -// - -#include "gl_load/gl_system.h" -#include "r_sky.h" -#include "r_utility.h" -#include "doomstat.h" -#include "g_levellocals.h" -#include "tarray.h" -#include "hwrenderer/scene/hw_drawstructs.h" -#include "hwrenderer/data/flatvertices.h" - -#include "gl/scene/gl_drawinfo.h" -#include "hwrenderer/scene/hw_clipper.h" -#include "gl/renderer/gl_renderstate.h" -#include "gl/renderer/gl_renderer.h" -#include "hwrenderer/data/hw_viewpointbuffer.h" -#include "hwrenderer/dynlights/hw_lightbuffer.h" -#include "hwrenderer/models/hw_models.h" - -void FDrawInfo::RenderPortal(HWPortal *p, bool usestencil) -{ - auto gp = static_cast(p); - gp->SetupStencil(this, gl_RenderState, usestencil); - auto new_di = StartDrawInfo(Viewpoint, &VPUniforms); - new_di->mCurrentPortal = gp; - gl_RenderState.SetLightIndex(-1); - gp->DrawContents(new_di, gl_RenderState); - new_di->EndDrawInfo(); - screen->mVertexData->Bind(gl_RenderState); - screen->mViewpoints->Bind(gl_RenderState, vpIndex); - gp->RemoveStencil(this, gl_RenderState, usestencil); - -} - diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h index b5b8d58518..4cf56dc8fd 100644 --- a/src/gl/scene/gl_drawinfo.h +++ b/src/gl/scene/gl_drawinfo.h @@ -13,8 +13,6 @@ struct FDrawInfo : public HWDrawInfo { - void RenderPortal(HWPortal *p, bool stencil) override; - void CreateScene(); void DrawScene(int drawmode) override; void ProcessScene(bool toscreen = false); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index d454bc63e4..a3bbcbdf86 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -172,7 +172,7 @@ void FDrawInfo::DrawScene(int drawmode) } glDepthMask(true); - if (!gl_no_skyclear) screen->mPortalState->RenderFirstSkyPortal(recursion, this); + if (!gl_no_skyclear) screen->mPortalState->RenderFirstSkyPortal(recursion, this, gl_RenderState); RenderScene(gl_RenderState); @@ -190,7 +190,7 @@ void FDrawInfo::DrawScene(int drawmode) // Handle all portals after rendering the opaque objects but before // doing all translucent stuff recursion++; - screen->mPortalState->EndFrame(this); + screen->mPortalState->EndFrame(this, gl_RenderState); recursion--; RenderTranslucent(gl_RenderState); } diff --git a/src/hwrenderer/scene/hw_drawinfo.cpp b/src/hwrenderer/scene/hw_drawinfo.cpp index 0efd1a0259..f8d800cd87 100644 --- a/src/hwrenderer/scene/hw_drawinfo.cpp +++ b/src/hwrenderer/scene/hw_drawinfo.cpp @@ -37,6 +37,7 @@ #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 "hw_clipper.h" @@ -514,3 +515,24 @@ void HWDrawInfo::RenderTranslucent(FRenderState &state) } +//----------------------------------------------------------------------------- +// +// RenderTranslucent +// +//----------------------------------------------------------------------------- + +void HWDrawInfo::RenderPortal(HWPortal *p, FRenderState &state, bool usestencil) +{ + auto gp = static_cast(p); + gp->SetupStencil(this, state, usestencil); + auto new_di = StartDrawInfo(Viewpoint, &VPUniforms); + new_di->mCurrentPortal = gp; + state.SetLightIndex(-1); + gp->DrawContents(new_di, state); + new_di->EndDrawInfo(); + screen->mVertexData->Bind(state); + screen->mViewpoints->Bind(state, vpIndex); + gp->RemoveStencil(this, state, usestencil); + +} + diff --git a/src/hwrenderer/scene/hw_drawinfo.h b/src/hwrenderer/scene/hw_drawinfo.h index 6b5e7d1cdc..fcc7d3f033 100644 --- a/src/hwrenderer/scene/hw_drawinfo.h +++ b/src/hwrenderer/scene/hw_drawinfo.h @@ -307,6 +307,7 @@ public: void RenderScene(FRenderState &state); void RenderTranslucent(FRenderState &state); + void RenderPortal(HWPortal *p, FRenderState &state, bool usestencil); bool DoOneSectorUpper(subsector_t * subsec, float planez, area_t in_area); bool DoOneSectorLower(subsector_t * subsec, float planez, area_t in_area); @@ -365,7 +366,6 @@ public: GLDecal *AddDecal(bool onmirror); - virtual void RenderPortal(HWPortal *p, bool usestencil) = 0; virtual void DrawScene(int drawmode) = 0; }; diff --git a/src/hwrenderer/scene/hw_portal.cpp b/src/hwrenderer/scene/hw_portal.cpp index 9beecbdf8e..0ae80a22cf 100644 --- a/src/hwrenderer/scene/hw_portal.cpp +++ b/src/hwrenderer/scene/hw_portal.cpp @@ -78,7 +78,7 @@ static FString indent; // //----------------------------------------------------------------------------- -void FPortalSceneState::EndFrame(HWDrawInfo *di) +void FPortalSceneState::EndFrame(HWDrawInfo *di, FRenderState &state) { HWPortal * p; @@ -96,7 +96,7 @@ void FPortalSceneState::EndFrame(HWDrawInfo *di) } if (p->lines.Size() > 0) { - RenderPortal(p, true, di); + RenderPortal(p, state, true, di); } delete p; } @@ -118,7 +118,7 @@ void FPortalSceneState::EndFrame(HWDrawInfo *di) // the GPU and there's rarely more than one sky visible at a time. // //----------------------------------------------------------------------------- -bool FPortalSceneState::RenderFirstSkyPortal(int recursion, HWDrawInfo *outer_di) +bool FPortalSceneState::RenderFirstSkyPortal(int recursion, HWDrawInfo *outer_di, FRenderState &state) { HWPortal * p; HWPortal * best = nullptr; @@ -147,7 +147,7 @@ bool FPortalSceneState::RenderFirstSkyPortal(int recursion, HWDrawInfo *outer_di if (best) { portals.Delete(bestindex); - RenderPortal(best, false, outer_di); + RenderPortal(best, state, false, outer_di); delete best; return true; } @@ -155,9 +155,9 @@ bool FPortalSceneState::RenderFirstSkyPortal(int recursion, HWDrawInfo *outer_di } -void FPortalSceneState::RenderPortal(HWPortal *p, bool usestencil, HWDrawInfo *outer_di) +void FPortalSceneState::RenderPortal(HWPortal *p, FRenderState &state, bool usestencil, HWDrawInfo *outer_di) { - if (gl_portals) outer_di->RenderPortal(p, usestencil); + if (gl_portals) outer_di->RenderPortal(p, state, usestencil); } diff --git a/src/hwrenderer/scene/hw_portal.h b/src/hwrenderer/scene/hw_portal.h index 50369f2322..31064d5f99 100644 --- a/src/hwrenderer/scene/hw_portal.h +++ b/src/hwrenderer/scene/hw_portal.h @@ -111,9 +111,9 @@ struct FPortalSceneState } void StartFrame(); - bool RenderFirstSkyPortal(int recursion, HWDrawInfo *outer_di); - void EndFrame(HWDrawInfo *outer_di); - void RenderPortal(HWPortal *p, bool usestencil, HWDrawInfo *outer_di); + bool RenderFirstSkyPortal(int recursion, HWDrawInfo *outer_di, FRenderState &state); + void EndFrame(HWDrawInfo *outer_di, FRenderState &state); + void RenderPortal(HWPortal *p, FRenderState &state, bool usestencil, HWDrawInfo *outer_di); }; inline HWPortal::HWPortal(FPortalSceneState *s, bool local) : mState(s)