- moved GLScenePortal to the hardware independent code.

This commit is contained in:
Christoph Oelckers 2018-10-24 07:57:32 +02:00
parent c76c4b77ec
commit e6b5eba469
7 changed files with 47 additions and 44 deletions

View file

@ -39,14 +39,6 @@ class GLViewpointBuffer;
struct FRenderViewpoint; struct FRenderViewpoint;
#define NOQUEUE nullptr // just some token to be used as a placeholder #define NOQUEUE nullptr // just some token to be used as a placeholder
enum
{
DM_MAINVIEW,
DM_OFFSCREEN,
DM_PORTAL,
DM_SKYPORTAL
};
class FGLRenderer class FGLRenderer
{ {
public: public:

View file

@ -242,10 +242,10 @@ void FDrawInfo::AddSubsectorToPortal(FSectorPortalGroup *ptg, subsector_t *sub)
auto portal = FindPortal(ptg); auto portal = FindPortal(ptg);
if (!portal) if (!portal)
{ {
portal = new GLScenePortal(&GLRenderer->mPortalState, new HWSectorStackPortal(ptg)); portal = new HWScenePortal(&GLRenderer->mPortalState, new HWSectorStackPortal(ptg));
Portals.Push(portal); Portals.Push(portal);
} }
auto ptl = static_cast<HWSectorStackPortal*>(static_cast<GLScenePortal*>(portal)->mScene); auto ptl = static_cast<HWSectorStackPortal*>(static_cast<HWScenePortal*>(portal)->mScene);
ptl->AddSubsector(sub); ptl->AddSubsector(sub);
} }

View file

@ -66,7 +66,7 @@ struct FDrawInfo : public HWDrawInfo
void CreateScene(); void CreateScene();
void RenderScene(int recursion); void RenderScene(int recursion);
void RenderTranslucent(); void RenderTranslucent();
void DrawScene(int drawmode); void DrawScene(int drawmode) override;
void ProcessScene(bool toscreen = false); void ProcessScene(bool toscreen = false);
void EndDrawScene(sector_t * viewsector); void EndDrawScene(sector_t * viewsector);
void DrawEndScene2D(sector_t * viewsector); void DrawEndScene2D(sector_t * viewsector);

View file

@ -46,34 +46,6 @@
struct GLEEHorizonPortal; 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<FDrawInfo*>(di)->DrawScene(DM_PORTAL);
mScene->Shutdown(di);
}
else di->ClearScreen();
}
virtual void RenderAttached(HWDrawInfo *di) { return mScene->RenderAttached(di); }
};
struct GLSkyPortal : public HWPortal struct GLSkyPortal : public HWPortal
{ {
GLSkyInfo * origin; GLSkyInfo * origin;

View file

@ -127,7 +127,7 @@ void FDrawInfo::AddPortal(GLWall *wall, int ptype)
if (wall->secportal->mType != PORTS_SKYVIEWPOINT) portal = new GLEEHorizonPortal(&pstate, wall->secportal); if (wall->secportal->mType != PORTS_SKYVIEWPOINT) portal = new GLEEHorizonPortal(&pstate, wall->secportal);
else else
{ {
portal = new GLScenePortal(&pstate, new HWSkyboxPortal(wall->secportal)); portal = new HWScenePortal(&pstate, new HWSkyboxPortal(wall->secportal));
Portals.Push(portal); Portals.Push(portal);
} }
} }
@ -138,7 +138,7 @@ void FDrawInfo::AddPortal(GLWall *wall, int ptype)
portal = FindPortal(wall->portal); portal = FindPortal(wall->portal);
if (!portal) if (!portal)
{ {
portal = new GLScenePortal(&pstate, new HWSectorStackPortal(wall->portal)); portal = new HWScenePortal(&pstate, new HWSectorStackPortal(wall->portal));
Portals.Push(portal); Portals.Push(portal);
} }
portal->AddLine(wall); portal->AddLine(wall);
@ -152,7 +152,7 @@ void FDrawInfo::AddPortal(GLWall *wall, int ptype)
portal = FindPortal(wall->planemirror); portal = FindPortal(wall->planemirror);
if (!portal) if (!portal)
{ {
portal = new GLScenePortal(&pstate, new HWPlaneMirrorPortal(wall->planemirror)); portal = new HWScenePortal(&pstate, new HWPlaneMirrorPortal(wall->planemirror));
Portals.Push(portal); Portals.Push(portal);
} }
portal->AddLine(wall); portal->AddLine(wall);
@ -163,7 +163,7 @@ void FDrawInfo::AddPortal(GLWall *wall, int ptype)
portal = FindPortal(wall->seg->linedef); portal = FindPortal(wall->seg->linedef);
if (!portal) if (!portal)
{ {
portal = new GLScenePortal(&pstate, new HWMirrorPortal(wall->seg->linedef)); portal = new HWScenePortal(&pstate, new HWMirrorPortal(wall->seg->linedef));
Portals.Push(portal); Portals.Push(portal);
} }
portal->AddLine(wall); portal->AddLine(wall);
@ -183,7 +183,7 @@ void FDrawInfo::AddPortal(GLWall *wall, int ptype)
{ {
ProcessActorsInPortal(otherside->getPortal()->mGroup, in_area); 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); Portals.Push(portal);
} }
portal->AddLine(wall); portal->AddLine(wall);

View file

@ -8,6 +8,15 @@
#include "v_video.h" #include "v_video.h"
#include "hw_weapon.h" #include "hw_weapon.h"
enum EDrawMode
{
DM_MAINVIEW,
DM_OFFSCREEN,
DM_PORTAL,
DM_SKYPORTAL
};
enum EDrawType enum EDrawType
{ {
DT_Points = 0, DT_Points = 0,
@ -339,6 +348,7 @@ public:
virtual void DrawModel(GLSprite *spr, FRenderState &state) = 0; virtual void DrawModel(GLSprite *spr, FRenderState &state) = 0;
virtual void DrawHUDModel(HUDSprite *spr, FRenderState &state) = 0; virtual void DrawHUDModel(HUDSprite *spr, FRenderState &state) = 0;
virtual void RenderPortal(HWPortal *p, bool usestencil) = 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. // Immediate render state change commands. These only change infrequently and should not clutter the render state.

View file

@ -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); }
};