Skip to content

Commit

Permalink
- moved all portal code that sets up a scene to be rendered into API …
Browse files Browse the repository at this point in the history
…independent code and let it be handled by a common wrapper class.
  • Loading branch information
coelckers committed Jun 23, 2018
1 parent 3936e30 commit 6ebec37
Show file tree
Hide file tree
Showing 13 changed files with 728 additions and 689 deletions.
38 changes: 16 additions & 22 deletions src/gl/scene/gl_drawinfo.cpp
Expand Up @@ -175,23 +175,6 @@ void FDrawInfoList::Release(FDrawInfo * di)
mList.Push(di);
}

//==========================================================================
//
//
//
//==========================================================================

FDrawInfo::FDrawInfo()
{
next = NULL;
}

FDrawInfo::~FDrawInfo()
{
ClearBuffers();
}


//==========================================================================
//
// Sets up a new drawinfo struct
Expand Down Expand Up @@ -225,15 +208,15 @@ void FDrawInfo::StartScene()
{
ClearBuffers();

next = gl_drawinfo;
outer = gl_drawinfo;
gl_drawinfo = this;
for (int i = 0; i < GLDL_TYPES; i++) drawlists[i].Reset();
decals[0].Clear();
decals[1].Clear();
hudsprites.Clear();

// Fullbright information needs to be propagated from the main view.
if (next != nullptr) FullbrightFlags = next->FullbrightFlags;
if (outer != nullptr) FullbrightFlags = outer->FullbrightFlags;
else FullbrightFlags = 0;

}
Expand All @@ -247,7 +230,7 @@ FDrawInfo *FDrawInfo::EndDrawInfo()
{
assert(this == gl_drawinfo);
for(int i=0;i<GLDL_TYPES;i++) drawlists[i].Reset();
gl_drawinfo=next;
gl_drawinfo=static_cast<FDrawInfo*>(outer);
di_list.Release(this);
if (gl_drawinfo == nullptr)
ResetRenderDataAllocator();
Expand Down Expand Up @@ -499,9 +482,15 @@ void FDrawInfo::FloodLowerGap(seg_t * seg)
}

// Same here for the dependency on the portal.
void FDrawInfo::AddSubsectorToPortal(FSectorPortalGroup *portal, subsector_t *sub)
void FDrawInfo::AddSubsectorToPortal(FSectorPortalGroup *ptg, subsector_t *sub)
{
portal->GetRenderState()->AddSubsector(sub);
auto portal = GLRenderer->mPortalState.FindPortal(ptg);
if (!portal)
{
portal = new GLScenePortal(&GLRenderer->mPortalState, new HWSectorStackPortal(ptg));
}
auto ptl = static_cast<HWSectorStackPortal*>(static_cast<GLScenePortal*>(portal)->mScene);
ptl->AddSubsector(sub);
}

std::pair<FFlatVertex *, unsigned int> FDrawInfo::AllocVertices(unsigned int count)
Expand All @@ -523,5 +512,10 @@ int FDrawInfo::UploadLights(FDynLightData &data)
return GLRenderer->mLights->UploadLights(data);
}

bool FDrawInfo::SetDepthClamp(bool on)
{
return gl_RenderState.SetDepthClamp(on);
}



16 changes: 2 additions & 14 deletions src/gl/scene/gl_drawinfo.h
Expand Up @@ -35,14 +35,10 @@ enum Drawpasses

struct FDrawInfo : public HWDrawInfo
{
FDrawInfo * next;
HWDrawList drawlists[GLDL_TYPES];
TArray<HUDSprite> hudsprites; // These may just be stored by value.
TArray<GLDecal *> decals[2]; // the second slot is for mirrors which get rendered in a separate pass.

FDrawInfo();
~FDrawInfo();

void ApplyVPUniforms() override;

void AddWall(GLWall *wall) override;
Expand All @@ -56,15 +52,6 @@ struct FDrawInfo : public HWDrawInfo
std::pair<FFlatVertex *, unsigned int> AllocVertices(unsigned int count) override;
int UploadLights(FDynLightData &data) override;

// Legacy GL only.
bool PutWallCompat(GLWall *wall, int passflag);
bool PutFlatCompat(GLFlat *flat, bool fog);
void RenderFogBoundaryCompat(GLWall *wall);
void RenderLightsCompat(GLWall *wall, int pass);
void DrawSubsectorLights(GLFlat *flat, subsector_t * sub, int pass);
void DrawLightsCompat(GLFlat *flat, int pass);


void DrawDecal(GLDecal *gldecal);
void DrawDecals();
void DrawDecalsForMirror(GLWall *wall);
Expand Down Expand Up @@ -111,7 +98,8 @@ struct FDrawInfo : public HWDrawInfo
void ProcessScene(bool toscreen = false);
void EndDrawScene(sector_t * viewsector);
void DrawEndScene2D(sector_t * viewsector);

bool SetDepthClamp(bool on) override;

static FDrawInfo *StartDrawInfo(FRenderViewpoint &parentvp, HWViewpointUniforms *uniforms);
FDrawInfo *EndDrawInfo();

Expand Down

0 comments on commit 6ebec37

Please sign in to comment.