diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 6d07483a2..615699ad6 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -97,38 +97,17 @@ static Clipper staticClipper; FDrawInfo *FDrawInfo::StartDrawInfo(FRenderViewpoint &parentvp, HWViewpointUniforms *uniforms) { FDrawInfo *di=di_list.GetNew(); - di->mClipper = &staticClipper; - di->Viewpoint = parentvp; - if (uniforms) - { - di->VPUniforms = *uniforms; - // The clip planes will never be inherited from the parent drawinfo. - di->VPUniforms.mClipLine.X = -1000001.f; - di->VPUniforms.mClipHeight = 0; - } - else di->VPUniforms.SetDefaults(); - di->mClipper->SetViewpoint(di->Viewpoint); staticClipper.Clear(); - di->StartScene(); + di->mClipper = &staticClipper; + + di->StartScene(parentvp, uniforms); + + di->outer = gl_drawinfo; + gl_drawinfo = di; + return di; } -void FDrawInfo::StartScene() -{ - ClearBuffers(); - - outer = gl_drawinfo; - gl_drawinfo = this; - for (int i = 0; i < GLDL_TYPES; i++) drawlists[i].Reset(); - hudsprites.Clear(); - vpIndex = 0; - - // Fullbright information needs to be propagated from the main view. - if (outer != nullptr) FullbrightFlags = outer->FullbrightFlags; - else FullbrightFlags = 0; - -} - //========================================================================== // // @@ -145,19 +124,6 @@ FDrawInfo *FDrawInfo::EndDrawInfo() return gl_drawinfo; } -// Same here for the dependency on the portal. -void FDrawInfo::AddSubsectorToPortal(FSectorPortalGroup *ptg, subsector_t *sub) -{ - auto portal = FindPortal(ptg); - if (!portal) - { - portal = new HWScenePortal(screen->mPortalState, new HWSectorStackPortal(ptg)); - Portals.Push(portal); - } - auto ptl = static_cast(static_cast(portal)->mScene); - ptl->AddSubsector(sub); -} - bool FDrawInfo::SetDepthClamp(bool on) { return gl_RenderState.SetDepthClamp(on); diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h index eddd40ce2..37b68c0fe 100644 --- a/src/gl/scene/gl_drawinfo.h +++ b/src/gl/scene/gl_drawinfo.h @@ -26,10 +26,6 @@ struct FDrawInfo : public HWDrawInfo void SetCulling(int mode) override; void EnableClipDistance(int num, bool state) override; - void StartScene(); - - void AddSubsectorToPortal(FSectorPortalGroup *portal, subsector_t *sub) override; - void CreateScene(); void RenderScene(int recursion); void RenderTranslucent(); diff --git a/src/hwrenderer/scene/hw_drawinfo.cpp b/src/hwrenderer/scene/hw_drawinfo.cpp index 8cd126d9f..bd74b5e05 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 "hw_clipper.h" EXTERN_CVAR(Float, r_visibility) CVAR(Bool, gl_bandedswlight, false, CVAR_ARCHIVE) @@ -60,6 +61,31 @@ inline void DeleteLinkedList(T *node) } } +void HWDrawInfo::StartScene(FRenderViewpoint &parentvp, HWViewpointUniforms *uniforms) +{ + Viewpoint = parentvp; + if (uniforms) + { + VPUniforms = *uniforms; + // The clip planes will never be inherited from the parent drawinfo. + VPUniforms.mClipLine.X = -1000001.f; + VPUniforms.mClipHeight = 0; + } + else VPUniforms.SetDefaults(); + mClipper->SetViewpoint(Viewpoint); + + ClearBuffers(); + + for (int i = 0; i < GLDL_TYPES; i++) drawlists[i].Reset(); + hudsprites.Clear(); + vpIndex = 0; + + // Fullbright information needs to be propagated from the main view. + if (outer != nullptr) FullbrightFlags = outer->FullbrightFlags; + else FullbrightFlags = 0; + +} + void HWDrawInfo::ClearBuffers() { for (auto node : otherfloorplanes) DeleteLinkedList(node); diff --git a/src/hwrenderer/scene/hw_drawinfo.h b/src/hwrenderer/scene/hw_drawinfo.h index acee209f9..878eb0977 100644 --- a/src/hwrenderer/scene/hw_drawinfo.h +++ b/src/hwrenderer/scene/hw_drawinfo.h @@ -298,6 +298,7 @@ public: HWPortal * FindPortal(const void * src); void RenderBSPNode(void *node); + void StartScene(FRenderViewpoint &parentvp, HWViewpointUniforms *uniforms); void ClearBuffers(); void SetViewArea(); int SetFullbrightFlags(player_t *player); @@ -349,7 +350,7 @@ public: void DrawPlayerSprites(bool hudModelStep, FRenderState &state); void ProcessLowerMinisegs(TArray &lowersegs); - virtual void AddSubsectorToPortal(FSectorPortalGroup *portal, subsector_t *sub) = 0; + void AddSubsectorToPortal(FSectorPortalGroup *portal, subsector_t *sub); void AddWall(GLWall *w); void AddMirrorSurface(GLWall *w); diff --git a/src/hwrenderer/scene/hw_renderhacks.cpp b/src/hwrenderer/scene/hw_renderhacks.cpp index b52cb023d..9610d3da7 100644 --- a/src/hwrenderer/scene/hw_renderhacks.cpp +++ b/src/hwrenderer/scene/hw_renderhacks.cpp @@ -37,6 +37,7 @@ #include "hwrenderer/dynlights/hw_dynlightdata.h" #include "hwrenderer/data/flatvertices.h" #include "hwrenderer/dynlights/hw_lightbuffer.h" +#include "hwrenderer/scene/hw_portal.h" sector_t * hw_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool back); @@ -1365,3 +1366,21 @@ void HWDrawInfo::ProcessSectorStacks(area_t in_area) CeilingStacks.Clear(); } +//========================================================================== +// +// +// +//========================================================================== + +void HWDrawInfo::AddSubsectorToPortal(FSectorPortalGroup *ptg, subsector_t *sub) +{ + auto portal = FindPortal(ptg); + if (!portal) + { + portal = new HWScenePortal(screen->mPortalState, new HWSectorStackPortal(ptg)); + Portals.Push(portal); + } + auto ptl = static_cast(static_cast(portal)->mScene); + ptl->AddSubsector(sub); +} +