diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index e69ce961e..5c7c983d3 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -582,20 +582,12 @@ void GLWall::RenderFogBoundaryCompat() // Flats // //========================================================================== -enum -{ - LIGHTPASS_MULT, - LIGHTPASS_ADD, - LIGHTPASS_FOG -}; void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass) { Plane p; Vector nearPt, up, right, t1; float scale; - unsigned int k; - seg_t *v; FLightNode * node = sub->lighthead; gl_RenderState.Apply(); @@ -603,33 +595,13 @@ void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass) { ADynamicLight * light = node->lightsource; - if (light->flags2&MF2_DORMANT) + if (light->flags2&MF2_DORMANT || + (pass == GLPASS_LIGHTTEX && light->IsAdditive()) || + (pass == GLPASS_LIGHTTEX_ADDITIVE && !light->IsAdditive())) { node = node->nextLight; continue; } - switch (pass) - { - case LIGHTPASS_MULT: - if (light->IsAdditive()) - { - node = node->nextLight; - continue; - } - break; - - case LIGHTPASS_ADD: - if (!light->IsAdditive()) - { - node = node->nextLight; - continue; - } - break; - - default: - break; - } - // we must do the side check here because gl_SetupLight needs the correct plane orientation // which we don't have for Legacy-style 3D-floors @@ -666,6 +638,49 @@ void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass) } } +//========================================================================== +// +// +// +//========================================================================== + +void GLFlat::DrawLightsCompat(int pass) +{ + gl_RenderState.Apply(); + if (sub) + { + // This represents a single subsector + DrawSubsectorLights(sub, pass); + } + else + { + // Draw the subsectors belonging to this sector + for (int i = 0; isubsectorcount; i++) + { + subsector_t * sub = sector->subsectors[i]; + if (gl_drawinfo->ss_renderflags[sub - subsectors] & renderflags) + { + DrawSubsectorLights(sub, pass); + } + } + + // Draw the subsectors assigned to it due to missing textures + if (!(renderflags&SSRF_RENDER3DPLANES)) + { + gl_subsectorrendernode * node = (renderflags&SSRF_RENDERFLOOR) ? + gl_drawinfo->GetOtherFloorPlanes(sector->sectornum) : + gl_drawinfo->GetOtherCeilingPlanes(sector->sectornum); + + while (node) + { + DrawSubsectorLights(sub, pass); + node = node->next; + } + } + } +} + + //========================================================================== // // diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 6b6f0e4a9..850a93615 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -443,6 +443,11 @@ void GLFlat::Draw(int pass, bool trans) // trans only has meaning for GLPASS_LIG } if (renderstyle==STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); break; + + case GLPASS_LIGHTTEX: + case GLPASS_LIGHTTEX_ADDITIVE: + DrawLightsCompat(pass); + break; } } diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index cb443cd2a..3bdcbd6ce 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -296,15 +296,18 @@ public: int dynlightindex; + // compatibility fallback stuff. + void DrawSubsectorLights(subsector_t * sub, int pass); + void DrawLightsCompat(int pass); + bool PutFlatCompat(bool fog); + void SetupSubsectorLights(int pass, subsector_t * sub, int *dli = NULL); void DrawSubsector(subsector_t * sub); - void DrawSubsectorLights(subsector_t * sub, int pass); void DrawSkyboxSector(int pass, bool processlights); void DrawSubsectors(int pass, bool processlights, bool istrans); void ProcessLights(bool istrans); void PutFlat(bool fog = false); - bool PutFlatCompat(bool fog); void Process(sector_t * model, int whichplane, bool notexture); void SetFrom3DFloor(F3DFloor *rover, bool top, bool underside); void ProcessSector(sector_t * frontsector);