diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp index 31b9e7182..c977b754d 100644 --- a/src/gl/compatibility/gl_20.cpp +++ b/src/gl/compatibility/gl_20.cpp @@ -590,11 +590,17 @@ bool GLFlat::PutFlatCompat(bool fog) // //========================================================================== -void GLWall::RenderFogBoundaryCompat() +void FDrawInfo::RenderFogBoundaryCompat(GLWall *wall) { // without shaders some approximation is needed. This won't look as good // as the shader version but it's an acceptable compromise. - float fogdensity = gl_GetFogDensity(lightlevel, Colormap.FadeColor, Colormap.FogDensity); + auto &Colormap = wall->Colormap; + auto &glseg = wall->glseg; + auto tcs = wall->tcs; + auto ztop = wall->ztop; + auto zbottom = wall->zbottom; + + float fogdensity = gl_GetFogDensity(wall->lightlevel, Colormap.FadeColor, Colormap.FogDensity); float dist1 = Dist2(r_viewpoint.Pos.X, r_viewpoint.Pos.Y, glseg.x1, glseg.y1); float dist2 = Dist2(r_viewpoint.Pos.X, r_viewpoint.Pos.Y, glseg.x2, glseg.y2); @@ -614,14 +620,14 @@ void GLWall::RenderFogBoundaryCompat() glDepthFunc(GL_LEQUAL); glColor4f(fc[0], fc[1], fc[2], fogd1); glBegin(GL_TRIANGLE_FAN); - glTexCoord2f(tcs[LOLFT].u, tcs[LOLFT].v); + glTexCoord2f(tcs[GLWall::LOLFT].u, tcs[GLWall::LOLFT].v); glVertex3f(glseg.x1, zbottom[0], glseg.y1); - glTexCoord2f(tcs[UPLFT].u, tcs[UPLFT].v); + glTexCoord2f(tcs[GLWall::UPLFT].u, tcs[GLWall::UPLFT].v); glVertex3f(glseg.x1, ztop[0], glseg.y1); glColor4f(fc[0], fc[1], fc[2], fogd2); - glTexCoord2f(tcs[UPRGT].u, tcs[UPRGT].v); + glTexCoord2f(tcs[GLWall::UPRGT].u, tcs[GLWall::UPRGT].v); glVertex3f(glseg.x2, ztop[1], glseg.y2); - glTexCoord2f(tcs[LORGT].u, tcs[LORGT].v); + glTexCoord2f(tcs[GLWall::LORGT].u, tcs[GLWall::LORGT].v); glVertex3f(glseg.x2, zbottom[1], glseg.y2); glEnd(); glDepthFunc(GL_LESS); @@ -733,8 +739,13 @@ void GLFlat::DrawLightsCompat(int pass) // Sets up the texture coordinates for one light to be rendered // //========================================================================== -bool GLWall::PrepareLight(ADynamicLight * light, int pass) +static bool PrepareLight(GLWall *wall, ADynamicLight * light, int pass) { + auto &glseg = wall->glseg; + auto tcs = wall->tcs; + auto ztop = wall->ztop; + auto zbottom = wall->zbottom; + float vtx[] = { glseg.x1,zbottom[0],glseg.y1, glseg.x1,ztop[0],glseg.y1, glseg.x2,ztop[1],glseg.y2, glseg.x2,zbottom[1],glseg.y2 }; Plane p; FVector3 nearPt, up, right; @@ -748,7 +759,7 @@ bool GLWall::PrepareLight(ADynamicLight * light, int pass) return false; } - if (!gl_SetupLight(seg->frontsector->PortalGroup, p, light, nearPt, up, right, scale, true, pass != GLPASS_LIGHTTEX)) + if (!gl_SetupLight(wall->seg->frontsector->PortalGroup, p, light, nearPt, up, right, scale, true, pass != GLPASS_LIGHTTEX)) { return false; } @@ -778,27 +789,27 @@ bool GLWall::PrepareLight(ADynamicLight * light, int pass) } -void GLWall::RenderLightsCompat(int pass) +void FDrawInfo::RenderLightsCompat(GLWall *wall, int pass) { FLightNode * node; // black fog is diminishing light and should affect lights less than the rest! - if (pass == GLPASS_LIGHTTEX) mDrawer->SetFog((255 + lightlevel) >> 1, 0, NULL, false); - else mDrawer->SetFog(lightlevel, 0, &Colormap, true); + if (pass == GLPASS_LIGHTTEX) mDrawer->SetFog((255 + wall->lightlevel) >> 1, 0, NULL, false); + else mDrawer->SetFog(wall->lightlevel, 0, &wall->Colormap, true); - if (seg->sidedef == NULL) + if (wall->seg->sidedef == NULL) { return; } - else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) + else if (!(wall->seg->sidedef->Flags & WALLF_POLYOBJ)) { // Iterate through all dynamic lights which touch this wall and render them - node = seg->sidedef->lighthead; + node = wall->seg->sidedef->lighthead; } - else if (sub) + else if (wall->sub) { // To avoid constant rechecking for polyobjects use the subsector's lightlist instead - node = sub->lighthead; + node = wall->sub->lighthead; } else { @@ -806,7 +817,7 @@ void GLWall::RenderLightsCompat(int pass) } texcoord save[4]; - memcpy(save, tcs, sizeof(tcs)); + memcpy(save, wall->tcs, sizeof(wall->tcs)); while (node) { ADynamicLight * light = node->lightsource; @@ -818,15 +829,15 @@ void GLWall::RenderLightsCompat(int pass) node = node->nextLight; continue; } - if (PrepareLight(light, pass)) + if (PrepareLight(wall, light, pass)) { - vertcount = 0; - RenderWall(RWF_TEXTURED); + wall->vertcount = 0; + wall->RenderWall(GLWall::RWF_TEXTURED); } node = node->nextLight; } - memcpy(tcs, save, sizeof(tcs)); - vertcount = 0; + memcpy(wall->tcs, save, sizeof(wall->tcs)); + wall->vertcount = 0; } //========================================================================== diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h index cce1ecd4b..06bdbafcc 100644 --- a/src/gl/scene/gl_drawinfo.h +++ b/src/gl/scene/gl_drawinfo.h @@ -181,8 +181,11 @@ struct FDrawInfo : public HWDrawInfo void AddMirrorSurface(GLWall *w) override; void ProcessActorsInPortal(FLinePortalSpan *glport) override; - bool PutWallCompat(GLWall *wall, int passflag); // Legacy GL only. - + // Legacy GL only. + bool PutWallCompat(GLWall *wall, int passflag); + void RenderFogBoundaryCompat(GLWall *wall); + void RenderLightsCompat(GLWall *wall, int pass); + void DrawDecal(GLWall *wall, DBaseDecal *decal); void DoDrawDecals(GLWall *wall); diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h index 2e84351f6..49642e838 100644 --- a/src/gl/scene/gl_wall.h +++ b/src/gl/scene/gl_wall.h @@ -203,15 +203,11 @@ private: void PutPortal(HWDrawInfo *di, int ptype); void CheckTexturePosition(FTexCoordInfo *tci); - void RenderFogBoundaryCompat(); - void RenderLightsCompat(int pass); - void Put3DWall(HWDrawInfo *di, lightlist_t * lightlist, bool translucent); bool SplitWallComplex(HWDrawInfo *di, sector_t * frontsector, bool translucent, float& maplightbottomleft, float& maplightbottomright); void SplitWall(HWDrawInfo *di, sector_t * frontsector, bool translucent); void SetupLights(); - bool PrepareLight(ADynamicLight * light, int pass); void MakeVertices(bool nosplit); void RenderWall(int textured); void RenderTextured(int rflags); diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index 6298635ae..d24750d79 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -235,7 +235,7 @@ void GLWall::RenderFogBoundary() } else { - RenderFogBoundaryCompat(); + gl_drawinfo->RenderFogBoundaryCompat(this); } } } @@ -450,7 +450,7 @@ void GLWall::Draw(int pass) case GLPASS_LIGHTTEX: case GLPASS_LIGHTTEX_ADDITIVE: case GLPASS_LIGHTTEX_FOGGY: - RenderLightsCompat(pass); + gl_drawinfo->RenderLightsCompat(this, pass); break; case GLPASS_TEXONLY: