From e6b5eba4693fb5254cd678fca3ea1678906a233e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 24 Oct 2018 07:57:32 +0200 Subject: [PATCH] - moved GLScenePortal to the hardware independent code. --- src/gl/renderer/gl_renderer.h | 8 -------- src/gl/scene/gl_drawinfo.cpp | 4 ++-- src/gl/scene/gl_drawinfo.h | 2 +- src/gl/scene/gl_portal.h | 28 ---------------------------- src/gl/scene/gl_walls_draw.cpp | 10 +++++----- src/hwrenderer/scene/hw_drawinfo.h | 10 ++++++++++ src/hwrenderer/scene/hw_portal.h | 29 +++++++++++++++++++++++++++++ 7 files changed, 47 insertions(+), 44 deletions(-) diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index bc04b813e..3be5e97ad 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -39,14 +39,6 @@ class GLViewpointBuffer; struct FRenderViewpoint; #define NOQUEUE nullptr // just some token to be used as a placeholder -enum -{ - DM_MAINVIEW, - DM_OFFSCREEN, - DM_PORTAL, - DM_SKYPORTAL -}; - class FGLRenderer { public: diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index b09381c31..f85bfb810 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -242,10 +242,10 @@ void FDrawInfo::AddSubsectorToPortal(FSectorPortalGroup *ptg, subsector_t *sub) auto portal = FindPortal(ptg); if (!portal) { - portal = new GLScenePortal(&GLRenderer->mPortalState, new HWSectorStackPortal(ptg)); + portal = new HWScenePortal(&GLRenderer->mPortalState, new HWSectorStackPortal(ptg)); Portals.Push(portal); } - auto ptl = static_cast(static_cast(portal)->mScene); + auto ptl = static_cast(static_cast(portal)->mScene); ptl->AddSubsector(sub); } diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h index f3816d353..8bd4d4670 100644 --- a/src/gl/scene/gl_drawinfo.h +++ b/src/gl/scene/gl_drawinfo.h @@ -66,7 +66,7 @@ struct FDrawInfo : public HWDrawInfo void CreateScene(); void RenderScene(int recursion); void RenderTranslucent(); - void DrawScene(int drawmode); + void DrawScene(int drawmode) override; void ProcessScene(bool toscreen = false); void EndDrawScene(sector_t * viewsector); void DrawEndScene2D(sector_t * viewsector); diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h index 27198a98e..6da1aecec 100644 --- a/src/gl/scene/gl_portal.h +++ b/src/gl/scene/gl_portal.h @@ -46,34 +46,6 @@ struct GLEEHorizonPortal; -class GLScenePortal : public HWPortal -{ -public: - HWScenePortalBase *mScene; - GLScenePortal(FPortalSceneState *state, HWScenePortalBase *handler) : HWPortal(state, false) - { - mScene = handler; - handler->SetOwner(this); - } - ~GLScenePortal() { delete mScene; } - virtual void * GetSource() const { return mScene->GetSource(); } - virtual const char *GetName() { return mScene->GetName(); } - virtual bool IsSky() { return mScene->IsSky(); } - virtual bool NeedCap() { return true; } - virtual bool NeedDepthBuffer() { return true; } - virtual void DrawContents(HWDrawInfo *di) - { - if (mScene->Setup(di, di->mClipper)) - { - static_cast(di)->DrawScene(DM_PORTAL); - mScene->Shutdown(di); - } - else di->ClearScreen(); - } - virtual void RenderAttached(HWDrawInfo *di) { return mScene->RenderAttached(di); } -}; - - struct GLSkyPortal : public HWPortal { GLSkyInfo * origin; diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index fbb50d4eb..1c9eb7101 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -127,7 +127,7 @@ void FDrawInfo::AddPortal(GLWall *wall, int ptype) if (wall->secportal->mType != PORTS_SKYVIEWPOINT) portal = new GLEEHorizonPortal(&pstate, wall->secportal); else { - portal = new GLScenePortal(&pstate, new HWSkyboxPortal(wall->secportal)); + portal = new HWScenePortal(&pstate, new HWSkyboxPortal(wall->secportal)); Portals.Push(portal); } } @@ -138,7 +138,7 @@ void FDrawInfo::AddPortal(GLWall *wall, int ptype) portal = FindPortal(wall->portal); if (!portal) { - portal = new GLScenePortal(&pstate, new HWSectorStackPortal(wall->portal)); + portal = new HWScenePortal(&pstate, new HWSectorStackPortal(wall->portal)); Portals.Push(portal); } portal->AddLine(wall); @@ -152,7 +152,7 @@ void FDrawInfo::AddPortal(GLWall *wall, int ptype) portal = FindPortal(wall->planemirror); if (!portal) { - portal = new GLScenePortal(&pstate, new HWPlaneMirrorPortal(wall->planemirror)); + portal = new HWScenePortal(&pstate, new HWPlaneMirrorPortal(wall->planemirror)); Portals.Push(portal); } portal->AddLine(wall); @@ -163,7 +163,7 @@ void FDrawInfo::AddPortal(GLWall *wall, int ptype) portal = FindPortal(wall->seg->linedef); if (!portal) { - portal = new GLScenePortal(&pstate, new HWMirrorPortal(wall->seg->linedef)); + portal = new HWScenePortal(&pstate, new HWMirrorPortal(wall->seg->linedef)); Portals.Push(portal); } portal->AddLine(wall); @@ -183,7 +183,7 @@ void FDrawInfo::AddPortal(GLWall *wall, int ptype) { ProcessActorsInPortal(otherside->getPortal()->mGroup, in_area); } - portal = new GLScenePortal(&pstate, new HWLineToLinePortal(wall->lineportal)); + portal = new HWScenePortal(&pstate, new HWLineToLinePortal(wall->lineportal)); Portals.Push(portal); } portal->AddLine(wall); diff --git a/src/hwrenderer/scene/hw_drawinfo.h b/src/hwrenderer/scene/hw_drawinfo.h index b4683a919..a490f5503 100644 --- a/src/hwrenderer/scene/hw_drawinfo.h +++ b/src/hwrenderer/scene/hw_drawinfo.h @@ -8,6 +8,15 @@ #include "v_video.h" #include "hw_weapon.h" +enum EDrawMode +{ + DM_MAINVIEW, + DM_OFFSCREEN, + DM_PORTAL, + DM_SKYPORTAL +}; + + enum EDrawType { DT_Points = 0, @@ -339,6 +348,7 @@ public: virtual void DrawModel(GLSprite *spr, FRenderState &state) = 0; virtual void DrawHUDModel(HUDSprite *spr, FRenderState &state) = 0; virtual void RenderPortal(HWPortal *p, bool usestencil) = 0; + virtual void DrawScene(int drawmode) = 0; // Immediate render state change commands. These only change infrequently and should not clutter the render state. diff --git a/src/hwrenderer/scene/hw_portal.h b/src/hwrenderer/scene/hw_portal.h index d9f0f287f..eaee2ba1e 100644 --- a/src/hwrenderer/scene/hw_portal.h +++ b/src/hwrenderer/scene/hw_portal.h @@ -305,3 +305,32 @@ public: }; + +class HWScenePortal : public HWPortal +{ +public: + HWScenePortalBase *mScene; + HWScenePortal(FPortalSceneState *state, HWScenePortalBase *handler) : HWPortal(state, false) + { + mScene = handler; + handler->SetOwner(this); + } + ~HWScenePortal() { delete mScene; } + virtual void * GetSource() const { return mScene->GetSource(); } + virtual const char *GetName() { return mScene->GetName(); } + virtual bool IsSky() { return mScene->IsSky(); } + virtual bool NeedCap() { return true; } + virtual bool NeedDepthBuffer() { return true; } + virtual void DrawContents(HWDrawInfo *di) + { + if (mScene->Setup(di, di->mClipper)) + { + di->DrawScene(DM_PORTAL); + mScene->Shutdown(di); + } + else di->ClearScreen(); + } + virtual void RenderAttached(HWDrawInfo *di) { return mScene->RenderAttached(di); } +}; + +