From c98474d1c7ef1a8ca1baa0b1b937098e80405035 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 25 Oct 2018 22:30:03 +0200 Subject: [PATCH] - portal refactoring complete. --- src/gl/data/gl_vertexbuffer.h | 1 - src/gl/scene/gl_drawinfo.h | 1 - src/hwrenderer/scene/hw_drawinfo.h | 1 - src/hwrenderer/scene/hw_portal.cpp | 6 +++--- src/hwrenderer/scene/hw_skydome.cpp | 2 ++ src/hwrenderer/scene/hw_walls.cpp | 5 +++-- src/v_video.h | 2 ++ 7 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h index 5393e20685..2ecaff47b1 100644 --- a/src/gl/data/gl_vertexbuffer.h +++ b/src/gl/data/gl_vertexbuffer.h @@ -58,7 +58,6 @@ public: FVertexBuffer(bool wantbuffer = true); virtual ~FVertexBuffer(); virtual void BindVBO() = 0; - void EnableBufferArrays(int enable, int disable); }; struct FSimpleVertex diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h index 8bd4d4670a..6393ac660e 100644 --- a/src/gl/scene/gl_drawinfo.h +++ b/src/gl/scene/gl_drawinfo.h @@ -36,7 +36,6 @@ struct FDrawInfo : public HWDrawInfo void AddWall(GLWall *wall) override; void AddMirrorSurface(GLWall *w) override; - void AddPortal(GLWall *w, int portaltype) override; void AddFlat(GLFlat *flat, bool fog) override; void AddSprite(GLSprite *sprite, bool translucent) override; diff --git a/src/hwrenderer/scene/hw_drawinfo.h b/src/hwrenderer/scene/hw_drawinfo.h index a490f55032..cb885202b3 100644 --- a/src/hwrenderer/scene/hw_drawinfo.h +++ b/src/hwrenderer/scene/hw_drawinfo.h @@ -329,7 +329,6 @@ public: virtual void AddSubsectorToPortal(FSectorPortalGroup *portal, subsector_t *sub) = 0; virtual void AddWall(GLWall *w) = 0; - virtual void AddPortal(GLWall *w, int portaltype) = 0; virtual void AddMirrorSurface(GLWall *w) = 0; virtual void AddFlat(GLFlat *flat, bool fog) = 0; virtual void AddSprite(GLSprite *sprite, bool translucent) = 0; diff --git a/src/hwrenderer/scene/hw_portal.cpp b/src/hwrenderer/scene/hw_portal.cpp index 0fa873737e..923d68eede 100644 --- a/src/hwrenderer/scene/hw_portal.cpp +++ b/src/hwrenderer/scene/hw_portal.cpp @@ -811,7 +811,7 @@ HWHorizonPortal::HWHorizonPortal(FPortalSceneState *s, GLHorizonInfo * pt, FRend // Draw to some far away boundary // This is not drawn as larger strips because it causes visual glitches. - auto verts = di->AllocVertices(256 + 10); + auto verts = di->AllocVertices(1024 + 10); auto ptr = verts.first; for (int xx = -32768; xx < 32768; xx += 4096) { @@ -855,7 +855,7 @@ HWHorizonPortal::HWHorizonPortal(FPortalSceneState *s, GLHorizonInfo * pt, FRend ptr++; voffset = verts.second; - vcount = 256; + vcount = 1024; } @@ -905,7 +905,7 @@ void HWHorizonPortal::DrawContents(HWDrawInfo *di, FRenderState &state) for (unsigned i = 0; i < vcount; i += 4) { - di->Draw(DT_TriangleStrip, state, voffset + i, 4, i==0); + di->Draw(DT_TriangleStrip, state, voffset + i, 4, true);// i == 0); } di->Draw(DT_TriangleStrip, state, voffset + vcount, 10, false); diff --git a/src/hwrenderer/scene/hw_skydome.cpp b/src/hwrenderer/scene/hw_skydome.cpp index de8a51af1e..449be72f60 100644 --- a/src/hwrenderer/scene/hw_skydome.cpp +++ b/src/hwrenderer/scene/hw_skydome.cpp @@ -81,11 +81,13 @@ EXTERN_CVAR(Float, skyoffset) FSkyDomeCreator::FSkyDomeCreator() { + screen->mSkyData = this; CreateDome(); } FSkyDomeCreator::~FSkyDomeCreator() { + if (screen && screen->mSkyData) screen->mSkyData = nullptr; } //----------------------------------------------------------------------------- diff --git a/src/hwrenderer/scene/hw_walls.cpp b/src/hwrenderer/scene/hw_walls.cpp index 8c69394117..2c65db7ff2 100644 --- a/src/hwrenderer/scene/hw_walls.cpp +++ b/src/hwrenderer/scene/hw_walls.cpp @@ -39,6 +39,7 @@ #include "hwrenderer/scene/hw_drawstructs.h" #include "hwrenderer/scene/hw_portal.h" #include "hw_renderstate.h" +#include "hw_skydome.h" //========================================================================== // @@ -470,7 +471,7 @@ void GLWall::PutPortal(HWDrawInfo *di, int ptype) break; case PORTALTYPE_SECTORSTACK: - portal = di->FindPortal(portal); + portal = di->FindPortal(this->portal); if (!portal) { portal = new HWScenePortal(pstate, new HWSectorStackPortal(this->portal)); @@ -529,7 +530,7 @@ void GLWall::PutPortal(HWDrawInfo *di, int ptype) portal = di->FindPortal(sky); if (!portal) { - portal = new HWSkyPortal(GLRenderer->mSkyVBO, &pstate, sky); + portal = new HWSkyPortal(screen->mSkyData, pstate, sky); di->Portals.Push(portal); } portal->AddLine(this); diff --git a/src/v_video.h b/src/v_video.h index 6b81e73153..7e583a92a5 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -49,6 +49,7 @@ struct sector_t; class IShaderProgram; class FTexture; struct FPortalSceneState; +class FSkyDomeCreator; enum EHWCaps { @@ -368,6 +369,7 @@ public: int stencilValue = 0; // Global stencil test value bool enable_quadbuffered = false; FPortalSceneState *mPortalState; // global portal state. + FSkyDomeCreator *mSkyData; // we need access to this in the device independent part, but cannot depend on how the renderer manages it internally. IntRect mScreenViewport; IntRect mSceneViewport;