From 77b301612a614882a90223a878f633b24e13ab2c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 29 Apr 2018 12:32:21 +0200 Subject: [PATCH] - some refactoring of GLDrawList to remove implementation-specific parts from this class. --- src/gl/compatibility/gl_20.cpp | 48 ++-- src/gl/scene/gl_drawinfo.cpp | 347 +++++++++++++++-------------- src/gl/scene/gl_drawinfo.h | 22 +- src/gl/scene/gl_scene.cpp | 32 +-- src/hwrenderer/scene/hw_drawinfo.h | 3 + 5 files changed, 232 insertions(+), 220 deletions(-) diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index 92b6e12bba..5bf7496eb2 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -857,8 +857,8 @@ void GLSceneDrawer::RenderMultipassStuff() gl_RenderState.EnableTexture(false); gl_RenderState.EnableBrightmap(false); gl_RenderState.Apply(); - gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(GLPASS_PLAIN); - gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_PLAIN); + gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(gl_drawinfo, GLPASS_PLAIN); + gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(gl_drawinfo, GLPASS_PLAIN); // 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 @@ -866,18 +866,18 @@ void GLSceneDrawer::RenderMultipassStuff() gl_RenderState.SetTextureMode(TM_MASK); gl_RenderState.EnableBrightmap(true); gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); - gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_PLAIN); - gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_PLAIN); + gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(gl_drawinfo, GLPASS_PLAIN); + gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(gl_drawinfo, GLPASS_PLAIN); // Part 3: The base of fogged surfaces, including the texture gl_RenderState.EnableBrightmap(false); gl_RenderState.SetTextureMode(TM_MODULATE); gl_RenderState.AlphaFunc(GL_GEQUAL, 0); - gl_drawinfo->dldrawlists[GLLDL_WALLS_FOG].DrawWalls(GLPASS_PLAIN); - gl_drawinfo->dldrawlists[GLLDL_FLATS_FOG].DrawFlats(GLPASS_PLAIN); + gl_drawinfo->dldrawlists[GLLDL_WALLS_FOG].DrawWalls(gl_drawinfo, GLPASS_PLAIN); + gl_drawinfo->dldrawlists[GLLDL_FLATS_FOG].DrawFlats(gl_drawinfo, GLPASS_PLAIN); gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); - gl_drawinfo->dldrawlists[GLLDL_WALLS_FOGMASKED].DrawWalls(GLPASS_PLAIN); - gl_drawinfo->dldrawlists[GLLDL_FLATS_FOGMASKED].DrawFlats(GLPASS_PLAIN); + gl_drawinfo->dldrawlists[GLLDL_WALLS_FOGMASKED].DrawWalls(gl_drawinfo, GLPASS_PLAIN); + gl_drawinfo->dldrawlists[GLLDL_FLATS_FOGMASKED].DrawFlats(gl_drawinfo, GLPASS_PLAIN); // second pass: draw lights glDepthMask(false); @@ -888,10 +888,10 @@ void GLSceneDrawer::RenderMultipassStuff() gl_RenderState.BlendFunc(GL_ONE, GL_ONE); glDepthFunc(GL_EQUAL); if (level.lightmode == 8) gl_RenderState.SetSoftLightLevel(255); - gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(GLPASS_LIGHTTEX); - gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_LIGHTTEX); - gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_LIGHTTEX); - gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_LIGHTTEX); + gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(gl_drawinfo, GLPASS_LIGHTTEX); + gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(gl_drawinfo, GLPASS_LIGHTTEX); + gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(gl_drawinfo, GLPASS_LIGHTTEX); + gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(gl_drawinfo, GLPASS_LIGHTTEX); gl_RenderState.BlendEquation(GL_FUNC_ADD); } else gl_lights = false; @@ -903,11 +903,11 @@ void GLSceneDrawer::RenderMultipassStuff() gl_RenderState.EnableFog(false); gl_RenderState.AlphaFunc(GL_GEQUAL, 0); glDepthFunc(GL_LEQUAL); - gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(GLPASS_TEXONLY); - gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_TEXONLY); + gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(gl_drawinfo, GLPASS_TEXONLY); + gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(gl_drawinfo, GLPASS_TEXONLY); gl_RenderState.AlphaFunc(GL_GREATER, gl_mask_threshold); - gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_TEXONLY); - gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_TEXONLY); + gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(gl_drawinfo, GLPASS_TEXONLY); + gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(gl_drawinfo, GLPASS_TEXONLY); // fourth pass: additive lights gl_RenderState.EnableFog(true); @@ -915,14 +915,14 @@ void GLSceneDrawer::RenderMultipassStuff() glDepthFunc(GL_EQUAL); if (gl_SetupLightTexture()) { - gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(GLPASS_LIGHTTEX_ADDITIVE); - gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_LIGHTTEX_ADDITIVE); - gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_LIGHTTEX_ADDITIVE); - gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_LIGHTTEX_ADDITIVE); - gl_drawinfo->dldrawlists[GLLDL_WALLS_FOG].DrawWalls(GLPASS_LIGHTTEX_FOGGY); - gl_drawinfo->dldrawlists[GLLDL_WALLS_FOGMASKED].DrawWalls(GLPASS_LIGHTTEX_FOGGY); - gl_drawinfo->dldrawlists[GLLDL_FLATS_FOG].DrawFlats(GLPASS_LIGHTTEX_FOGGY); - gl_drawinfo->dldrawlists[GLLDL_FLATS_FOGMASKED].DrawFlats(GLPASS_LIGHTTEX_FOGGY); + gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(gl_drawinfo, GLPASS_LIGHTTEX_ADDITIVE); + gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(gl_drawinfo, GLPASS_LIGHTTEX_ADDITIVE); + gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(gl_drawinfo, GLPASS_LIGHTTEX_ADDITIVE); + gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(gl_drawinfo, GLPASS_LIGHTTEX_ADDITIVE); + gl_drawinfo->dldrawlists[GLLDL_WALLS_FOG].DrawWalls(gl_drawinfo, GLPASS_LIGHTTEX_FOGGY); + gl_drawinfo->dldrawlists[GLLDL_WALLS_FOGMASKED].DrawWalls(gl_drawinfo, GLPASS_LIGHTTEX_FOGGY); + gl_drawinfo->dldrawlists[GLLDL_FLATS_FOG].DrawFlats(gl_drawinfo, GLPASS_LIGHTTEX_FOGGY); + gl_drawinfo->dldrawlists[GLLDL_FLATS_FOGMASKED].DrawFlats(gl_drawinfo, GLPASS_LIGHTTEX_FOGGY); } else gl_lights = false; diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp index 14b9fd1c39..db6c61f183 100644 --- a/src/gl/scene/gl_drawinfo.cpp +++ b/src/gl/scene/gl_drawinfo.cpp @@ -351,7 +351,7 @@ void GLDrawList::SortSpriteIntoPlane(SortNode * head, SortNode * sort) // Splitting is done in the shader with clip planes, if available. // The fallback here only really works for non-y-billboarded sprites. - if (gl.flags & RFL_NO_CLIP_PLANES) + if (screen->hwcaps & RFL_NO_CLIP_PLANES) { float newtexv = ss->vt + ((ss->vb - ss->vt) / (ss->z2 - ss->z1))*(fh->z - ss->z1); @@ -481,8 +481,6 @@ EXTERN_CVAR(Int, gl_billboard_mode) EXTERN_CVAR(Bool, gl_billboard_faces_camera) EXTERN_CVAR(Bool, gl_billboard_particles) - - inline double CalcIntersectionVertex(GLSprite *s, GLWall * w2) { float ax = s->x1, ay = s->y1; @@ -492,8 +490,6 @@ inline double CalcIntersectionVertex(GLSprite *s, GLWall * w2) return ((ay - cy)*(dx - cx) - (ax - cx)*(dy - cy)) / ((bx - ax)*(dy - cy) - (by - ay)*(dx - cx)); } - - void GLDrawList::SortSpriteIntoWall(SortNode * head,SortNode * sort) { GLWall *wh= walls[drawitems[head->itemindex].index]; @@ -696,177 +692,15 @@ SortNode * GLDrawList::DoSort(SortNode * head) return sn; } - //========================================================================== // // // //========================================================================== -void GLDrawList::DoDraw(int pass, int i, bool trans) +void GLDrawList::Sort() { - switch(drawitems[i].rendertype) - { - case GLDIT_FLAT: - { - GLFlat * f= flats[drawitems[i].index]; - RenderFlat.Clock(); - gl_drawinfo->DrawFlat(f, pass, trans); - RenderFlat.Unclock(); - } - break; - - case GLDIT_WALL: - { - GLWall * w= walls[drawitems[i].index]; - RenderWall.Clock(); - gl_drawinfo->DrawWall(w, pass); - RenderWall.Unclock(); - } - break; - - case GLDIT_SPRITE: - { - GLSprite * s= sprites[drawitems[i].index]; - RenderSprite.Clock(); - gl_drawinfo->DrawSprite(s, pass); - RenderSprite.Unclock(); - } - break; - } -} - -//========================================================================== -// -// -// -//========================================================================== -void GLDrawList::DoDrawSorted(SortNode * head) -{ - float clipsplit[2]; - int relation = 0; - float z = 0.f; - - gl_RenderState.GetClipSplit(clipsplit); - - if (drawitems[head->itemindex].rendertype == GLDIT_FLAT) - { - z = flats[drawitems[head->itemindex].index]->z; - relation = z > r_viewpoint.Pos.Z ? 1 : -1; - } - - - // left is further away, i.e. for stuff above viewz its z coordinate higher, for stuff below viewz its z coordinate is lower - if (head->left) - { - if (relation == -1) - { - gl_RenderState.SetClipSplit(clipsplit[0], z); // render below: set flat as top clip plane - } - else if (relation == 1) - { - gl_RenderState.SetClipSplit(z, clipsplit[1]); // render above: set flat as bottom clip plane - } - DoDrawSorted(head->left); - gl_RenderState.SetClipSplit(clipsplit); - } - DoDraw(GLPASS_TRANSLUCENT, head->itemindex, true); - if (head->equal) - { - SortNode * ehead=head->equal; - while (ehead) - { - DoDraw(GLPASS_TRANSLUCENT, ehead->itemindex, true); - ehead=ehead->equal; - } - } - // right is closer, i.e. for stuff above viewz its z coordinate is lower, for stuff below viewz its z coordinate is higher - if (head->right) - { - if (relation == 1) - { - gl_RenderState.SetClipSplit(clipsplit[0], z); // render below: set flat as top clip plane - } - else if (relation == -1) - { - gl_RenderState.SetClipSplit(z, clipsplit[1]); // render above: set flat as bottom clip plane - } - DoDrawSorted(head->right); - gl_RenderState.SetClipSplit(clipsplit); - } -} - -//========================================================================== -// -// -// -//========================================================================== -void GLDrawList::DrawSorted() -{ - if (drawitems.Size()==0) return; - - if (!sorted) - { - GLRenderer->mVBO->Map(); - MakeSortList(); - sorted=DoSort(SortNodes[SortNodeStart]); - GLRenderer->mVBO->Unmap(); - } - gl_RenderState.ClearClipSplit(); - if (!(gl.flags & RFL_NO_CLIP_PLANES)) - { - glEnable(GL_CLIP_DISTANCE1); - glEnable(GL_CLIP_DISTANCE2); - } - DoDrawSorted(sorted); - if (!(gl.flags & RFL_NO_CLIP_PLANES)) - { - glDisable(GL_CLIP_DISTANCE1); - glDisable(GL_CLIP_DISTANCE2); - } - gl_RenderState.ClearClipSplit(); -} - -//========================================================================== -// -// -// -//========================================================================== -void GLDrawList::Draw(int pass, bool trans) -{ - for(unsigned i=0;iDrawWall(walls[item.index], pass); - } - RenderWall.Unclock(); -} - -//========================================================================== -// -// -// -//========================================================================== -void GLDrawList::DrawFlats(int pass) -{ - RenderFlat.Clock(); - for(unsigned i=0;iDrawFlat(flats[drawitems[i].index], pass, false); - } - RenderFlat.Unclock(); + MakeSortList(); + sorted = DoSort(SortNodes[SortNodeStart]); } //========================================================================== @@ -904,6 +738,7 @@ void GLDrawList::SortFlats() } } + //========================================================================== // // @@ -941,6 +776,178 @@ GLSprite *GLDrawList::NewSprite() return sprite; } +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::DoDraw(HWDrawInfo *di, int pass, int i, bool trans) +{ + switch(drawitems[i].rendertype) + { + case GLDIT_FLAT: + { + GLFlat * f= flats[drawitems[i].index]; + RenderFlat.Clock(); + di->DrawFlat(f, pass, trans); + RenderFlat.Unclock(); + } + break; + + case GLDIT_WALL: + { + GLWall * w= walls[drawitems[i].index]; + RenderWall.Clock(); + di->DrawWall(w, pass); + RenderWall.Unclock(); + } + break; + + case GLDIT_SPRITE: + { + GLSprite * s= sprites[drawitems[i].index]; + RenderSprite.Clock(); + gl_drawinfo->DrawSprite(s, pass); + RenderSprite.Unclock(); + } + break; + } +} + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::Draw(HWDrawInfo *di, int pass, bool trans) +{ + for (unsigned i = 0; i < drawitems.Size(); i++) + { + DoDraw(di, pass, i, trans); + } +} + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::DrawWalls(HWDrawInfo *di, int pass) +{ + RenderWall.Clock(); + for (auto &item : drawitems) + { + di->DrawWall(walls[item.index], pass); + } + RenderWall.Unclock(); +} + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::DrawFlats(HWDrawInfo *di, int pass) +{ + RenderFlat.Clock(); + for (unsigned i = 0; iDrawFlat(flats[drawitems[i].index], pass, false); + } + RenderFlat.Unclock(); +} + +//========================================================================== +// +// +// +//========================================================================== +void FDrawInfo::DoDrawSorted(GLDrawList *dl, SortNode * head) +{ + float clipsplit[2]; + int relation = 0; + float z = 0.f; + + gl_RenderState.GetClipSplit(clipsplit); + + if (dl->drawitems[head->itemindex].rendertype == GLDIT_FLAT) + { + z = dl->flats[dl->drawitems[head->itemindex].index]->z; + relation = z > r_viewpoint.Pos.Z ? 1 : -1; + } + + + // left is further away, i.e. for stuff above viewz its z coordinate higher, for stuff below viewz its z coordinate is lower + if (head->left) + { + if (relation == -1) + { + gl_RenderState.SetClipSplit(clipsplit[0], z); // render below: set flat as top clip plane + } + else if (relation == 1) + { + gl_RenderState.SetClipSplit(z, clipsplit[1]); // render above: set flat as bottom clip plane + } + DoDrawSorted(dl, head->left); + gl_RenderState.SetClipSplit(clipsplit); + } + dl->DoDraw(gl_drawinfo, GLPASS_TRANSLUCENT, head->itemindex, true); + if (head->equal) + { + SortNode * ehead=head->equal; + while (ehead) + { + dl->DoDraw(gl_drawinfo, GLPASS_TRANSLUCENT, ehead->itemindex, true); + ehead=ehead->equal; + } + } + // right is closer, i.e. for stuff above viewz its z coordinate is lower, for stuff below viewz its z coordinate is higher + if (head->right) + { + if (relation == 1) + { + gl_RenderState.SetClipSplit(clipsplit[0], z); // render below: set flat as top clip plane + } + else if (relation == -1) + { + gl_RenderState.SetClipSplit(z, clipsplit[1]); // render above: set flat as bottom clip plane + } + DoDrawSorted(dl, head->right); + gl_RenderState.SetClipSplit(clipsplit); + } +} + +//========================================================================== +// +// +// +//========================================================================== +void FDrawInfo::DrawSorted(int listindex) +{ + GLDrawList *dl = &drawlists[listindex]; + if (dl->drawitems.Size()==0) return; + + if (!dl->sorted) + { + GLRenderer->mVBO->Map(); + dl->Sort(); + GLRenderer->mVBO->Unmap(); + } + gl_RenderState.ClearClipSplit(); + if (!(gl.flags & RFL_NO_CLIP_PLANES)) + { + glEnable(GL_CLIP_DISTANCE1); + glEnable(GL_CLIP_DISTANCE2); + } + DoDrawSorted(dl, dl->sorted); + if (!(gl.flags & RFL_NO_CLIP_PLANES)) + { + glDisable(GL_CLIP_DISTANCE1); + glDisable(GL_CLIP_DISTANCE2); + } + gl_RenderState.ClearClipSplit(); +} + //========================================================================== // // Try to reuse the lists as often as possible as they contain resources that diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h index 9f7f05f7b8..29b62887d8 100644 --- a/src/gl/scene/gl_drawinfo.h +++ b/src/gl/scene/gl_drawinfo.h @@ -156,13 +156,12 @@ public: int CompareSprites(SortNode * a,SortNode * b); SortNode * SortSpriteList(SortNode * head); SortNode * DoSort(SortNode * head); - - void DoDraw(int pass, int index, bool trans); - void DoDrawSorted(SortNode * node); - void DrawSorted(); - void Draw(int pass, bool trans = false); - void DrawWalls(int pass); - void DrawFlats(int pass); + void Sort(); + + void DoDraw(HWDrawInfo *di, int pass, int index, bool trans); + void Draw(HWDrawInfo *di, int pass, bool trans = false); + void DrawWalls(HWDrawInfo *di, int pass); + void DrawFlats(HWDrawInfo *di, int pass); GLDrawList * next; } ; @@ -215,10 +214,10 @@ struct FDrawInfo : public HWDrawInfo void RenderMirrorSurface(GLWall *wall); void RenderTranslucentWall(GLWall *wall); void RenderTexturedWall(GLWall *wall, int rflags); - void DrawWall(GLWall *wall, int pass); + void DrawWall(GLWall *wall, int pass) override; // Flat drawer - void DrawFlat(GLFlat *flat, int pass, bool trans); // trans only has meaning for GLPASS_LIGHTSONLY + void DrawFlat(GLFlat *flat, int pass, bool trans) override; // trans only has meaning for GLPASS_LIGHTSONLY void DrawSkyboxSector(GLFlat *flat, int pass, bool processlights); void DrawSubsectors(GLFlat *flat, int pass, bool processlights, bool istrans); void ProcessLights(GLFlat *flat, bool istrans); @@ -227,7 +226,10 @@ struct FDrawInfo : public HWDrawInfo // Sprite drawer void DrawSprite(GLSprite *sprite, int pass); - + + void DoDrawSorted(GLDrawList *dl, SortNode * head); + void DrawSorted(int listindex); + // These two may be moved to the API independent part of the renderer later. void ProcessLowerMinisegs(TArray &lowersegs) override; void AddSubsectorToPortal(FSectorPortalGroup *portal, subsector_t *sub) override; diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 601dfb24c9..59f391f701 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -310,14 +310,14 @@ void GLSceneDrawer::RenderScene(int recursion) if (gl.lightmethod == LM_DEFERRED && haslights) { GLRenderer->mLights->Begin(); - gl_drawinfo->drawlists[GLDL_PLAINWALLS].DrawWalls(GLPASS_LIGHTSONLY); - gl_drawinfo->drawlists[GLDL_PLAINFLATS].DrawFlats(GLPASS_LIGHTSONLY); - gl_drawinfo->drawlists[GLDL_MASKEDWALLS].DrawWalls(GLPASS_LIGHTSONLY); - gl_drawinfo->drawlists[GLDL_MASKEDFLATS].DrawFlats(GLPASS_LIGHTSONLY); - gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].DrawWalls(GLPASS_LIGHTSONLY); - gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].Draw(GLPASS_LIGHTSONLY); - gl_drawinfo->drawlists[GLDL_TRANSLUCENT].Draw(GLPASS_LIGHTSONLY, true); - gl_drawinfo->drawlists[GLDL_MODELS].Draw(GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_PLAINWALLS].DrawWalls(gl_drawinfo, GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_PLAINFLATS].DrawFlats(gl_drawinfo, GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_MASKEDWALLS].DrawWalls(gl_drawinfo, GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_MASKEDFLATS].DrawFlats(gl_drawinfo, GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].DrawWalls(gl_drawinfo, GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].Draw(gl_drawinfo, GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_TRANSLUCENT].Draw(gl_drawinfo, GLPASS_LIGHTSONLY, true); + gl_drawinfo->drawlists[GLDL_MODELS].Draw(gl_drawinfo, GLPASS_LIGHTSONLY); SetupWeaponLight(); GLRenderer->mLights->Finish(); } @@ -348,8 +348,8 @@ void GLSceneDrawer::RenderScene(int recursion) gl_RenderState.EnableTexture(gl_texture); gl_RenderState.EnableBrightmap(true); - gl_drawinfo->drawlists[GLDL_PLAINWALLS].DrawWalls(pass); - gl_drawinfo->drawlists[GLDL_PLAINFLATS].DrawFlats(pass); + gl_drawinfo->drawlists[GLDL_PLAINWALLS].DrawWalls(gl_drawinfo, pass); + gl_drawinfo->drawlists[GLDL_PLAINFLATS].DrawFlats(gl_drawinfo, pass); // Part 2: masked geometry. This is set up so that only pixels with alpha>gl_mask_threshold will show @@ -359,20 +359,20 @@ void GLSceneDrawer::RenderScene(int recursion) gl_RenderState.SetTextureMode(TM_MASK); } gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); - gl_drawinfo->drawlists[GLDL_MASKEDWALLS].DrawWalls(pass); - gl_drawinfo->drawlists[GLDL_MASKEDFLATS].DrawFlats(pass); + gl_drawinfo->drawlists[GLDL_MASKEDWALLS].DrawWalls(gl_drawinfo, pass); + gl_drawinfo->drawlists[GLDL_MASKEDFLATS].DrawFlats(gl_drawinfo, 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. if (gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].Size() > 0) { glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(-1.0f, -128.0f); - gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].DrawWalls(pass); + gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].DrawWalls(gl_drawinfo, pass); glDisable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(0, 0); } - gl_drawinfo->drawlists[GLDL_MODELS].Draw(pass); + gl_drawinfo->drawlists[GLDL_MODELS].Draw(gl_drawinfo, pass); gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -428,8 +428,8 @@ void GLSceneDrawer::RenderTranslucent() gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.EnableBrightmap(true); - gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].Draw(GLPASS_TRANSLUCENT); - gl_drawinfo->drawlists[GLDL_TRANSLUCENT].DrawSorted(); + gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].Draw(gl_drawinfo, GLPASS_TRANSLUCENT); + gl_drawinfo->DrawSorted(GLDL_TRANSLUCENT); gl_RenderState.EnableBrightmap(false); diff --git a/src/hwrenderer/scene/hw_drawinfo.h b/src/hwrenderer/scene/hw_drawinfo.h index a1fc623f68..38218c46df 100644 --- a/src/hwrenderer/scene/hw_drawinfo.h +++ b/src/hwrenderer/scene/hw_drawinfo.h @@ -143,6 +143,9 @@ public: void GetDynSpriteLight(AActor *self, float x, float y, float z, subsector_t * subsec, float *out); void GetDynSpriteLight(AActor *thing, particle_t *particle, float *out); + virtual void DrawWall(GLWall *wall, int pass) = 0; + virtual void DrawFlat(GLFlat *flat, int pass, bool trans) = 0; + virtual void DrawSprite(GLSprite *sprite, int pass) = 0; virtual void FloodUpperGap(seg_t * seg) = 0; virtual void FloodLowerGap(seg_t * seg) = 0;