- removed gl_drawinfo-> from FDrawInfo member functions and pass it to some other functions as a parameter.

This really shouldn't be handled as a global variable. The mere fact that several member functions used it incorrectly is ample proof of that.
This commit is contained in:
Christoph Oelckers 2018-05-21 10:49:24 +02:00
parent 3069b53804
commit 31263eeac2
9 changed files with 82 additions and 82 deletions

View file

@ -586,7 +586,7 @@ bool FDrawInfo::PutFlatCompat(GLFlat *flat, bool fog)
int list = list_indices[masked][foggy]; int list = list_indices[masked][foggy];
auto newflat = gl_drawinfo->dldrawlists[list].NewFlat(); auto newflat = dldrawlists[list].NewFlat();
*newflat = *flat; *newflat = *flat;
return true; return true;
} }
@ -720,7 +720,7 @@ void FDrawInfo::DrawLightsCompat(GLFlat *flat, int pass)
for (int i = 0; i<flat->sector->subsectorcount; i++) for (int i = 0; i<flat->sector->subsectorcount; i++)
{ {
subsector_t * sub = flat->sector->subsectors[i]; subsector_t * sub = flat->sector->subsectors[i];
if (gl_drawinfo->ss_renderflags[sub->Index()] & flat->renderflags) if (ss_renderflags[sub->Index()] & flat->renderflags)
{ {
DrawSubsectorLights(flat, sub, pass); DrawSubsectorLights(flat, sub, pass);
} }
@ -730,8 +730,8 @@ void FDrawInfo::DrawLightsCompat(GLFlat *flat, int pass)
if (!(flat->renderflags&SSRF_RENDER3DPLANES)) if (!(flat->renderflags&SSRF_RENDER3DPLANES))
{ {
gl_subsectorrendernode * node = (flat->renderflags&SSRF_RENDERFLOOR) ? gl_subsectorrendernode * node = (flat->renderflags&SSRF_RENDERFLOOR) ?
gl_drawinfo->GetOtherFloorPlanes(flat->sector->sectornum) : GetOtherFloorPlanes(flat->sector->sectornum) :
gl_drawinfo->GetOtherCeilingPlanes(flat->sector->sectornum); GetOtherCeilingPlanes(flat->sector->sectornum);
while (node) while (node)
{ {
@ -854,7 +854,7 @@ void FDrawInfo::RenderLightsCompat(GLWall *wall, int pass)
// //
//========================================================================== //==========================================================================
void GLSceneDrawer::RenderMultipassStuff() void GLSceneDrawer::RenderMultipassStuff(FDrawInfo *di)
{ {
// First pass: empty background with sector light only // First pass: empty background with sector light only
@ -864,8 +864,8 @@ void GLSceneDrawer::RenderMultipassStuff()
gl_RenderState.EnableTexture(false); gl_RenderState.EnableTexture(false);
gl_RenderState.EnableBrightmap(false); gl_RenderState.EnableBrightmap(false);
gl_RenderState.Apply(); gl_RenderState.Apply();
gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(gl_drawinfo, GLPASS_ALL); di->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(di, GLPASS_ALL);
gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(gl_drawinfo, GLPASS_ALL); di->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(di, GLPASS_ALL);
// Part 2: masked geometry. This is set up so that only pixels with alpha>0.5 will show // Part 2: masked geometry. This is set up so that only pixels with alpha>0.5 will show
// This creates a blank surface that only fills the nontransparent parts of the texture // This creates a blank surface that only fills the nontransparent parts of the texture
@ -873,18 +873,18 @@ void GLSceneDrawer::RenderMultipassStuff()
gl_RenderState.SetTextureMode(TM_MASK); gl_RenderState.SetTextureMode(TM_MASK);
gl_RenderState.EnableBrightmap(true); gl_RenderState.EnableBrightmap(true);
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold);
gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(gl_drawinfo, GLPASS_ALL); di->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(di, GLPASS_ALL);
gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(gl_drawinfo, GLPASS_ALL); di->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(di, GLPASS_ALL);
// Part 3: The base of fogged surfaces, including the texture // Part 3: The base of fogged surfaces, including the texture
gl_RenderState.EnableBrightmap(false); gl_RenderState.EnableBrightmap(false);
gl_RenderState.SetTextureMode(TM_MODULATE); gl_RenderState.SetTextureMode(TM_MODULATE);
gl_RenderState.AlphaFunc(GL_GEQUAL, 0); gl_RenderState.AlphaFunc(GL_GEQUAL, 0);
gl_drawinfo->dldrawlists[GLLDL_WALLS_FOG].DrawWalls(gl_drawinfo, GLPASS_ALL); di->dldrawlists[GLLDL_WALLS_FOG].DrawWalls(di, GLPASS_ALL);
gl_drawinfo->dldrawlists[GLLDL_FLATS_FOG].DrawFlats(gl_drawinfo, GLPASS_ALL); di->dldrawlists[GLLDL_FLATS_FOG].DrawFlats(di, GLPASS_ALL);
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold);
gl_drawinfo->dldrawlists[GLLDL_WALLS_FOGMASKED].DrawWalls(gl_drawinfo, GLPASS_ALL); di->dldrawlists[GLLDL_WALLS_FOGMASKED].DrawWalls(di, GLPASS_ALL);
gl_drawinfo->dldrawlists[GLLDL_FLATS_FOGMASKED].DrawFlats(gl_drawinfo, GLPASS_ALL); di->dldrawlists[GLLDL_FLATS_FOGMASKED].DrawFlats(di, GLPASS_ALL);
// second pass: draw lights // second pass: draw lights
glDepthMask(false); glDepthMask(false);
@ -895,10 +895,10 @@ void GLSceneDrawer::RenderMultipassStuff()
gl_RenderState.BlendFunc(GL_ONE, GL_ONE); gl_RenderState.BlendFunc(GL_ONE, GL_ONE);
glDepthFunc(GL_EQUAL); glDepthFunc(GL_EQUAL);
if (level.lightmode == 8) gl_RenderState.SetSoftLightLevel(255); if (level.lightmode == 8) gl_RenderState.SetSoftLightLevel(255);
gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(gl_drawinfo, GLPASS_LIGHTTEX); di->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(di, GLPASS_LIGHTTEX);
gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(gl_drawinfo, GLPASS_LIGHTTEX); di->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(di, GLPASS_LIGHTTEX);
gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(gl_drawinfo, GLPASS_LIGHTTEX); di->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(di, GLPASS_LIGHTTEX);
gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(gl_drawinfo, GLPASS_LIGHTTEX); di->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(di, GLPASS_LIGHTTEX);
gl_RenderState.BlendEquation(GL_FUNC_ADD); gl_RenderState.BlendEquation(GL_FUNC_ADD);
} }
else gl_lights = false; else gl_lights = false;
@ -910,11 +910,11 @@ void GLSceneDrawer::RenderMultipassStuff()
gl_RenderState.EnableFog(false); gl_RenderState.EnableFog(false);
gl_RenderState.AlphaFunc(GL_GEQUAL, 0); gl_RenderState.AlphaFunc(GL_GEQUAL, 0);
glDepthFunc(GL_LEQUAL); glDepthFunc(GL_LEQUAL);
gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(gl_drawinfo, GLPASS_TEXONLY); di->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(di, GLPASS_TEXONLY);
gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(gl_drawinfo, GLPASS_TEXONLY); di->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(di, GLPASS_TEXONLY);
gl_RenderState.AlphaFunc(GL_GREATER, gl_mask_threshold); gl_RenderState.AlphaFunc(GL_GREATER, gl_mask_threshold);
gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(gl_drawinfo, GLPASS_TEXONLY); di->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(di, GLPASS_TEXONLY);
gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(gl_drawinfo, GLPASS_TEXONLY); di->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(di, GLPASS_TEXONLY);
// fourth pass: additive lights // fourth pass: additive lights
gl_RenderState.EnableFog(true); gl_RenderState.EnableFog(true);
@ -922,14 +922,14 @@ void GLSceneDrawer::RenderMultipassStuff()
glDepthFunc(GL_EQUAL); glDepthFunc(GL_EQUAL);
if (gl_SetupLightTexture()) if (gl_SetupLightTexture())
{ {
gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(gl_drawinfo, GLPASS_LIGHTTEX_ADDITIVE); di->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(di, GLPASS_LIGHTTEX_ADDITIVE);
gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(gl_drawinfo, GLPASS_LIGHTTEX_ADDITIVE); di->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(di, GLPASS_LIGHTTEX_ADDITIVE);
gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(gl_drawinfo, GLPASS_LIGHTTEX_ADDITIVE); di->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(di, GLPASS_LIGHTTEX_ADDITIVE);
gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(gl_drawinfo, GLPASS_LIGHTTEX_ADDITIVE); di->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(di, GLPASS_LIGHTTEX_ADDITIVE);
gl_drawinfo->dldrawlists[GLLDL_WALLS_FOG].DrawWalls(gl_drawinfo, GLPASS_LIGHTTEX_FOGGY); di->dldrawlists[GLLDL_WALLS_FOG].DrawWalls(di, GLPASS_LIGHTTEX_FOGGY);
gl_drawinfo->dldrawlists[GLLDL_WALLS_FOGMASKED].DrawWalls(gl_drawinfo, GLPASS_LIGHTTEX_FOGGY); di->dldrawlists[GLLDL_WALLS_FOGMASKED].DrawWalls(di, GLPASS_LIGHTTEX_FOGGY);
gl_drawinfo->dldrawlists[GLLDL_FLATS_FOG].DrawFlats(gl_drawinfo, GLPASS_LIGHTTEX_FOGGY); di->dldrawlists[GLLDL_FLATS_FOG].DrawFlats(di, GLPASS_LIGHTTEX_FOGGY);
gl_drawinfo->dldrawlists[GLLDL_FLATS_FOGMASKED].DrawFlats(gl_drawinfo, GLPASS_LIGHTTEX_FOGGY); di->dldrawlists[GLLDL_FLATS_FOGMASKED].DrawFlats(di, GLPASS_LIGHTTEX_FOGGY);
} }
else gl_lights = false; else gl_lights = false;

View file

@ -81,13 +81,13 @@ void FDrawInfo::DoDrawSorted(HWDrawList *dl, SortNode * head)
DoDrawSorted(dl, head->left); DoDrawSorted(dl, head->left);
gl_RenderState.SetClipSplit(clipsplit); gl_RenderState.SetClipSplit(clipsplit);
} }
dl->DoDraw(gl_drawinfo, GLPASS_TRANSLUCENT, head->itemindex, true); dl->DoDraw(this, GLPASS_TRANSLUCENT, head->itemindex, true);
if (head->equal) if (head->equal)
{ {
SortNode * ehead=head->equal; SortNode * ehead=head->equal;
while (ehead) while (ehead)
{ {
dl->DoDraw(gl_drawinfo, GLPASS_TRANSLUCENT, ehead->itemindex, true); dl->DoDraw(this, GLPASS_TRANSLUCENT, ehead->itemindex, true);
ehead=ehead->equal; ehead=ehead->equal;
} }
} }

View file

@ -141,7 +141,7 @@ void FDrawInfo::ProcessLights(GLFlat *flat, bool istrans)
for (int i=0; i< flat->sector->subsectorcount; i++) for (int i=0; i< flat->sector->subsectorcount; i++)
{ {
subsector_t * sub = flat->sector->subsectors[i]; subsector_t * sub = flat->sector->subsectors[i];
if (gl_drawinfo->ss_renderflags[sub->Index()]& flat->renderflags || istrans) if (ss_renderflags[sub->Index()]& flat->renderflags || istrans)
{ {
SetupSubsectorLights(flat, GLPASS_LIGHTSONLY, sub, nullptr); SetupSubsectorLights(flat, GLPASS_LIGHTSONLY, sub, nullptr);
} }
@ -151,8 +151,8 @@ void FDrawInfo::ProcessLights(GLFlat *flat, bool istrans)
if (!(flat->renderflags&SSRF_RENDER3DPLANES)) if (!(flat->renderflags&SSRF_RENDER3DPLANES))
{ {
gl_subsectorrendernode * node = (flat->renderflags&SSRF_RENDERFLOOR)? gl_subsectorrendernode * node = (flat->renderflags&SSRF_RENDERFLOOR)?
gl_drawinfo->GetOtherFloorPlanes(flat->sector->sectornum) : GetOtherFloorPlanes(flat->sector->sectornum) :
gl_drawinfo->GetOtherCeilingPlanes(flat->sector->sectornum); GetOtherCeilingPlanes(flat->sector->sectornum);
while (node) while (node)
{ {
@ -182,7 +182,7 @@ void FDrawInfo::DrawSubsectors(GLFlat *flat, int pass, bool processlights, bool
{ {
subsector_t * sub = flat->sector->subsectors[i]; subsector_t * sub = flat->sector->subsectors[i];
if (gl_drawinfo->ss_renderflags[sub->Index()]& flat->renderflags || istrans) if (ss_renderflags[sub->Index()]& flat->renderflags || istrans)
{ {
if (processlights) SetupSubsectorLights(flat, GLPASS_ALL, sub, &dli); if (processlights) SetupSubsectorLights(flat, GLPASS_ALL, sub, &dli);
drawcalls.Clock(); drawcalls.Clock();
@ -201,7 +201,7 @@ void FDrawInfo::DrawSubsectors(GLFlat *flat, int pass, bool processlights, bool
for (int i=0; i<flat->sector->subsectorcount; i++) for (int i=0; i<flat->sector->subsectorcount; i++)
{ {
subsector_t * sub = flat->sector->subsectors[i]; subsector_t * sub = flat->sector->subsectors[i];
if (gl_drawinfo->ss_renderflags[sub->Index()]& flat->renderflags || istrans) if (ss_renderflags[sub->Index()]& flat->renderflags || istrans)
{ {
if (processlights) SetupSubsectorLights(flat, GLPASS_ALL, sub, &dli); if (processlights) SetupSubsectorLights(flat, GLPASS_ALL, sub, &dli);
DrawSubsector(flat, sub); DrawSubsector(flat, sub);
@ -213,8 +213,8 @@ void FDrawInfo::DrawSubsectors(GLFlat *flat, int pass, bool processlights, bool
if (!(flat->renderflags&SSRF_RENDER3DPLANES)) if (!(flat->renderflags&SSRF_RENDER3DPLANES))
{ {
gl_subsectorrendernode * node = (flat->renderflags&SSRF_RENDERFLOOR)? gl_subsectorrendernode * node = (flat->renderflags&SSRF_RENDERFLOOR)?
gl_drawinfo->GetOtherFloorPlanes(flat->sector->sectornum) : GetOtherFloorPlanes(flat->sector->sectornum) :
gl_drawinfo->GetOtherCeilingPlanes(flat->sector->sectornum); GetOtherCeilingPlanes(flat->sector->sectornum);
while (node) while (node)
{ {
@ -399,7 +399,7 @@ void FDrawInfo::AddFlat(GLFlat *flat, bool fog)
bool masked = flat->gltexture->isMasked() && ((flat->renderflags&SSRF_RENDER3DPLANES) || flat->stack); bool masked = flat->gltexture->isMasked() && ((flat->renderflags&SSRF_RENDER3DPLANES) || flat->stack);
list = masked ? GLDL_MASKEDFLATS : GLDL_PLAINFLATS; list = masked ? GLDL_MASKEDFLATS : GLDL_PLAINFLATS;
} }
auto newflat = gl_drawinfo->drawlists[list].NewFlat(); auto newflat = drawlists[list].NewFlat();
*newflat = *flat; *newflat = *flat;
} }

View file

@ -688,7 +688,7 @@ GLSectorStackPortal::~GLSectorStackPortal()
// //
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static uint8_t SetCoverage(void *node) static uint8_t SetCoverage(FDrawInfo *di, void *node)
{ {
if (level.nodes.Size() == 0) if (level.nodes.Size() == 0)
{ {
@ -697,18 +697,18 @@ static uint8_t SetCoverage(void *node)
if (!((size_t)node & 1)) // Keep going until found a subsector if (!((size_t)node & 1)) // Keep going until found a subsector
{ {
node_t *bsp = (node_t *)node; node_t *bsp = (node_t *)node;
uint8_t coverage = SetCoverage(bsp->children[0]) | SetCoverage(bsp->children[1]); uint8_t coverage = SetCoverage(di, bsp->children[0]) | SetCoverage(di, bsp->children[1]);
gl_drawinfo->no_renderflags[bsp->Index()] = coverage; gl_drawinfo->no_renderflags[bsp->Index()] = coverage;
return coverage; return coverage;
} }
else else
{ {
subsector_t *sub = (subsector_t *)((uint8_t *)node - 1); subsector_t *sub = (subsector_t *)((uint8_t *)node - 1);
return gl_drawinfo->ss_renderflags[sub->Index()] & SSRF_SEEN; return di->ss_renderflags[sub->Index()] & SSRF_SEEN;
} }
} }
void GLSectorStackPortal::SetupCoverage() void GLSectorStackPortal::SetupCoverage(FDrawInfo *di)
{ {
for(unsigned i=0; i<subsectors.Size(); i++) for(unsigned i=0; i<subsectors.Size(); i++)
{ {
@ -721,7 +721,7 @@ void GLSectorStackPortal::SetupCoverage()
gl_drawinfo->ss_renderflags[dsub->Index()] |= SSRF_SEEN; gl_drawinfo->ss_renderflags[dsub->Index()] |= SSRF_SEEN;
} }
} }
SetCoverage(::level.HeadNode()); SetCoverage(di, ::level.HeadNode());
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -742,7 +742,7 @@ void GLSectorStackPortal::DrawContents()
drawer->SetupView(r_viewpoint.Pos.X, r_viewpoint.Pos.Y, r_viewpoint.Pos.Z, r_viewpoint.Angles.Yaw, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); drawer->SetupView(r_viewpoint.Pos.X, r_viewpoint.Pos.Y, r_viewpoint.Pos.Z, r_viewpoint.Angles.Yaw, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
SaveMapSection(); SaveMapSection();
SetupCoverage(); SetupCoverage(gl_drawinfo);
ClearClipper(); ClearClipper();
// If the viewpoint is not within the portal, we need to invalidate the entire clip area. // If the viewpoint is not within the portal, we need to invalidate the entire clip area.

View file

@ -302,7 +302,7 @@ public:
{ {
origin=pt; origin=pt;
} }
void SetupCoverage(); void SetupCoverage(FDrawInfo *di);
void AddSubsector(subsector_t *sub) void AddSubsector(subsector_t *sub)
{ {
subsectors.Push(sub); subsectors.Push(sub);

View file

@ -253,7 +253,7 @@ void GLSceneDrawer::CreateScene()
SetView(); SetView();
validcount++; // used for processing sidedefs only once by the renderer. validcount++; // used for processing sidedefs only once by the renderer.
gl_drawinfo->clipPortal = !!GLRenderer->mClipPortal; gl_drawinfo->clipPortal = !!GLRenderer->mClipPortal;
gl_drawinfo->mAngles = GLRenderer->mAngles; gl_drawinfo->mAngles = GLRenderer->mAngles;
gl_drawinfo->mViewVector = GLRenderer->mViewVector; gl_drawinfo->mViewVector = GLRenderer->mViewVector;
@ -289,7 +289,7 @@ void GLSceneDrawer::CreateScene()
// //
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void GLSceneDrawer::RenderScene(int recursion) void GLSceneDrawer::RenderScene(FDrawInfo *di, int recursion)
{ {
RenderAll.Clock(); RenderAll.Clock();
@ -303,11 +303,11 @@ void GLSceneDrawer::RenderScene(int recursion)
if (gl_sort_textures) if (gl_sort_textures)
{ {
gl_drawinfo->drawlists[GLDL_PLAINWALLS].SortWalls(); di->drawlists[GLDL_PLAINWALLS].SortWalls();
gl_drawinfo->drawlists[GLDL_PLAINFLATS].SortFlats(); di->drawlists[GLDL_PLAINFLATS].SortFlats();
gl_drawinfo->drawlists[GLDL_MASKEDWALLS].SortWalls(); di->drawlists[GLDL_MASKEDWALLS].SortWalls();
gl_drawinfo->drawlists[GLDL_MASKEDFLATS].SortFlats(); di->drawlists[GLDL_MASKEDFLATS].SortFlats();
gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].SortWalls(); di->drawlists[GLDL_MASKEDWALLSOFS].SortWalls();
} }
// if we don't have a persistently mapped buffer, we have to process all the dynamic lights up front, // if we don't have a persistently mapped buffer, we have to process all the dynamic lights up front,
@ -315,10 +315,10 @@ void GLSceneDrawer::RenderScene(int recursion)
if (gl.lightmethod == LM_DEFERRED && level.HasDynamicLights && FixedColormap == CM_DEFAULT) if (gl.lightmethod == LM_DEFERRED && level.HasDynamicLights && FixedColormap == CM_DEFAULT)
{ {
GLRenderer->mLights->Begin(); GLRenderer->mLights->Begin();
gl_drawinfo->drawlists[GLDL_PLAINFLATS].DrawFlats(gl_drawinfo, GLPASS_LIGHTSONLY); di->drawlists[GLDL_PLAINFLATS].DrawFlats(di, GLPASS_LIGHTSONLY);
gl_drawinfo->drawlists[GLDL_MASKEDFLATS].DrawFlats(gl_drawinfo, GLPASS_LIGHTSONLY); di->drawlists[GLDL_MASKEDFLATS].DrawFlats(di, GLPASS_LIGHTSONLY);
gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].Draw(gl_drawinfo, GLPASS_LIGHTSONLY); di->drawlists[GLDL_TRANSLUCENTBORDER].Draw(di, GLPASS_LIGHTSONLY);
gl_drawinfo->drawlists[GLDL_TRANSLUCENT].Draw(gl_drawinfo, GLPASS_LIGHTSONLY, true); di->drawlists[GLDL_TRANSLUCENT].Draw(di, GLPASS_LIGHTSONLY, true);
GLRenderer->mLights->Finish(); GLRenderer->mLights->Finish();
} }
@ -336,7 +336,7 @@ void GLSceneDrawer::RenderScene(int recursion)
else // GL 2.x legacy mode else // GL 2.x legacy mode
{ {
// process everything that needs to handle textured dynamic lights. // process everything that needs to handle textured dynamic lights.
if (level.HasDynamicLights) RenderMultipassStuff(); if (level.HasDynamicLights) RenderMultipassStuff(di);
// The remaining lists which are unaffected by dynamic lights are just processed as normal. // The remaining lists which are unaffected by dynamic lights are just processed as normal.
pass = GLPASS_ALL; pass = GLPASS_ALL;
@ -344,8 +344,8 @@ void GLSceneDrawer::RenderScene(int recursion)
gl_RenderState.EnableTexture(gl_texture); gl_RenderState.EnableTexture(gl_texture);
gl_RenderState.EnableBrightmap(true); gl_RenderState.EnableBrightmap(true);
gl_drawinfo->drawlists[GLDL_PLAINWALLS].DrawWalls(gl_drawinfo, pass); di->drawlists[GLDL_PLAINWALLS].DrawWalls(di, pass);
gl_drawinfo->drawlists[GLDL_PLAINFLATS].DrawFlats(gl_drawinfo, pass); di->drawlists[GLDL_PLAINFLATS].DrawFlats(di, pass);
// Part 2: masked geometry. This is set up so that only pixels with alpha>gl_mask_threshold will show // Part 2: masked geometry. This is set up so that only pixels with alpha>gl_mask_threshold will show
@ -355,20 +355,20 @@ void GLSceneDrawer::RenderScene(int recursion)
gl_RenderState.SetTextureMode(TM_MASK); gl_RenderState.SetTextureMode(TM_MASK);
} }
gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold);
gl_drawinfo->drawlists[GLDL_MASKEDWALLS].DrawWalls(gl_drawinfo, pass); di->drawlists[GLDL_MASKEDWALLS].DrawWalls(di, pass);
gl_drawinfo->drawlists[GLDL_MASKEDFLATS].DrawFlats(gl_drawinfo, pass); di->drawlists[GLDL_MASKEDFLATS].DrawFlats(di, pass);
// Part 3: masked geometry with polygon offset. This list is empty most of the time so only waste time on it when in use. // Part 3: masked geometry with polygon offset. This list is empty most of the time so only waste time on it when in use.
if (gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].Size() > 0) if (di->drawlists[GLDL_MASKEDWALLSOFS].Size() > 0)
{ {
glEnable(GL_POLYGON_OFFSET_FILL); glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(-1.0f, -128.0f); glPolygonOffset(-1.0f, -128.0f);
gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].DrawWalls(gl_drawinfo, pass); di->drawlists[GLDL_MASKEDWALLSOFS].DrawWalls(di, pass);
glDisable(GL_POLYGON_OFFSET_FILL); glDisable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(0, 0); glPolygonOffset(0, 0);
} }
gl_drawinfo->drawlists[GLDL_MODELS].Draw(gl_drawinfo, pass); di->drawlists[GLDL_MODELS].Draw(di, pass);
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@ -377,7 +377,7 @@ void GLSceneDrawer::RenderScene(int recursion)
glEnable(GL_POLYGON_OFFSET_FILL); glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(-1.0f, -128.0f); glPolygonOffset(-1.0f, -128.0f);
glDepthMask(false); glDepthMask(false);
gl_drawinfo->DrawDecals(); di->DrawDecals();
gl_RenderState.SetTextureMode(TM_MODULATE); gl_RenderState.SetTextureMode(TM_MODULATE);
@ -395,7 +395,7 @@ void GLSceneDrawer::RenderScene(int recursion)
gl_RenderState.EnableFog(true); gl_RenderState.EnableFog(true);
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
gl_RenderState.BlendFunc(GL_ONE,GL_ZERO); gl_RenderState.BlendFunc(GL_ONE,GL_ZERO);
gl_drawinfo->DrawUnhandledMissingTextures(); di->DrawUnhandledMissingTextures();
glDepthMask(true); glDepthMask(true);
glPolygonOffset(0.0f, 0.0f); glPolygonOffset(0.0f, 0.0f);
@ -478,7 +478,7 @@ void GLSceneDrawer::DrawScene(int drawmode)
} }
GLRenderer->mClipPortal = NULL; // this must be reset before any portal recursion takes place. GLRenderer->mClipPortal = NULL; // this must be reset before any portal recursion takes place.
RenderScene(recursion); RenderScene(gl_drawinfo, recursion);
if (applySSAO && gl_RenderState.GetPassType() == GBUFFER_PASS) if (applySSAO && gl_RenderState.GetPassType() == GBUFFER_PASS)
{ {
@ -505,7 +505,7 @@ void GLSceneDrawer::DrawScene(int drawmode)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void GLSceneDrawer::EndDrawScene(sector_t * viewsector) void GLSceneDrawer::EndDrawScene(FDrawInfo *di, sector_t * viewsector)
{ {
gl_RenderState.EnableFog(false); gl_RenderState.EnableFog(false);
@ -515,7 +515,7 @@ void GLSceneDrawer::EndDrawScene(sector_t * viewsector)
{ {
// [BB] The HUD model should be drawn over everything else already drawn. // [BB] The HUD model should be drawn over everything else already drawn.
glClear(GL_DEPTH_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT);
gl_drawinfo->DrawPlayerSprites(true); di->DrawPlayerSprites(true);
} }
glDisable(GL_STENCIL_TEST); glDisable(GL_STENCIL_TEST);
@ -525,7 +525,7 @@ void GLSceneDrawer::EndDrawScene(sector_t * viewsector)
// Delay drawing psprites until after bloom has been applied, if enabled. // Delay drawing psprites until after bloom has been applied, if enabled.
if (!FGLRenderBuffers::IsEnabled() || !gl_bloom || FixedColormap != CM_DEFAULT) if (!FGLRenderBuffers::IsEnabled() || !gl_bloom || FixedColormap != CM_DEFAULT)
{ {
DrawEndScene2D(viewsector); DrawEndScene2D(di, viewsector);
} }
else else
{ {
@ -537,7 +537,7 @@ void GLSceneDrawer::EndDrawScene(sector_t * viewsector)
} }
} }
void GLSceneDrawer::DrawEndScene2D(sector_t * viewsector) void GLSceneDrawer::DrawEndScene2D(FDrawInfo *di, sector_t * viewsector)
{ {
const bool renderHUDModel = gl_IsHUDModelForPlayerAvailable(players[consoleplayer].camera->player); const bool renderHUDModel = gl_IsHUDModelForPlayerAvailable(players[consoleplayer].camera->player);
@ -549,7 +549,7 @@ void GLSceneDrawer::DrawEndScene2D(sector_t * viewsector)
glDisable(GL_MULTISAMPLE); glDisable(GL_MULTISAMPLE);
gl_drawinfo->DrawPlayerSprites(false); di->DrawPlayerSprites(false);
if (gl.legacyMode) if (gl.legacyMode)
{ {
@ -696,11 +696,11 @@ sector_t * GLSceneDrawer::RenderViewpoint (AActor * camera, IntRect * bounds, fl
FDrawInfo::StartDrawInfo(this); FDrawInfo::StartDrawInfo(this);
ProcessScene(toscreen); ProcessScene(toscreen);
if (mainview && toscreen) EndDrawScene(lviewsector); // do not call this for camera textures. if (mainview && toscreen) EndDrawScene(gl_drawinfo, lviewsector); // do not call this for camera textures.
if (mainview && FGLRenderBuffers::IsEnabled()) if (mainview && FGLRenderBuffers::IsEnabled())
{ {
GLRenderer->PostProcessScene(FixedColormap, [&]() { if (gl_bloom && FixedColormap == CM_DEFAULT) DrawEndScene2D(lviewsector); }); GLRenderer->PostProcessScene(FixedColormap, [&]() { if (gl_bloom && FixedColormap == CM_DEFAULT) DrawEndScene2D(gl_drawinfo, lviewsector); });
// This should be done after postprocessing, not before. // This should be done after postprocessing, not before.
GLRenderer->mBuffers->BindCurrentFB(); GLRenderer->mBuffers->BindCurrentFB();

View file

@ -20,7 +20,7 @@ class GLSceneDrawer
TMap<DPSprite*, int> weapondynlightindex; TMap<DPSprite*, int> weapondynlightindex;
void RenderMultipassStuff(); void RenderMultipassStuff(FDrawInfo *di);
void UnclipSubsector(subsector_t *sub); void UnclipSubsector(subsector_t *sub);
void AddLine (seg_t *seg, bool portalclip); void AddLine (seg_t *seg, bool portalclip);
@ -33,7 +33,7 @@ class GLSceneDrawer
void DoSubsector(subsector_t * sub); void DoSubsector(subsector_t * sub);
void RenderBSPNode(void *node); void RenderBSPNode(void *node);
void RenderScene(int recursion); void RenderScene(FDrawInfo *di, int recursion);
void RenderTranslucent(); void RenderTranslucent();
void CreateScene(); void CreateScene();
@ -60,8 +60,8 @@ public:
void SetFixedColormap(player_t *player); void SetFixedColormap(player_t *player);
void DrawScene(int drawmode); void DrawScene(int drawmode);
void ProcessScene(bool toscreen = false); void ProcessScene(bool toscreen = false);
void EndDrawScene(sector_t * viewsector); void EndDrawScene(FDrawInfo *di, sector_t * viewsector);
void DrawEndScene2D(sector_t * viewsector); void DrawEndScene2D(FDrawInfo *di, sector_t * viewsector);
sector_t *RenderViewpoint(AActor * camera, IntRect * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen); sector_t *RenderViewpoint(AActor * camera, IntRect * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen);
sector_t *RenderView(player_t *player); sector_t *RenderView(player_t *player);

View file

@ -327,7 +327,7 @@ void FDrawInfo::AddSprite(GLSprite *sprite, bool translucent)
list = GLDL_MODELS; list = GLDL_MODELS;
} }
auto newsprt = gl_drawinfo->drawlists[list].NewSprite(); auto newsprt = drawlists[list].NewSprite();
*newsprt = *sprite; *newsprt = *sprite;
} }

View file

@ -142,7 +142,7 @@ void FDrawInfo::RenderMirrorSurface(GLWall *wall)
glEnable(GL_POLYGON_OFFSET_FILL); glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(-1.0f, -128.0f); glPolygonOffset(-1.0f, -128.0f);
glDepthMask(false); glDepthMask(false);
gl_drawinfo->DrawDecalsForMirror(wall); DrawDecalsForMirror(wall);
glDepthMask(true); glDepthMask(true);
glPolygonOffset(0.0f, 0.0f); glPolygonOffset(0.0f, 0.0f);
glDisable(GL_POLYGON_OFFSET_FILL); glDisable(GL_POLYGON_OFFSET_FILL);
@ -293,7 +293,7 @@ void FDrawInfo::DrawWall(GLWall *wall, int pass)
case GLPASS_LIGHTTEX: case GLPASS_LIGHTTEX:
case GLPASS_LIGHTTEX_ADDITIVE: case GLPASS_LIGHTTEX_ADDITIVE:
case GLPASS_LIGHTTEX_FOGGY: case GLPASS_LIGHTTEX_FOGGY:
gl_drawinfo->RenderLightsCompat(wall, pass); RenderLightsCompat(wall, pass);
break; break;
case GLPASS_TEXONLY: case GLPASS_TEXONLY: