- moved the legacy member functions of GLWall to FDrawInfo.

This commit is contained in:
Christoph Oelckers 2018-04-25 22:58:56 +02:00
parent 41d5bd76d4
commit 1ae6ad2a82
4 changed files with 40 additions and 30 deletions

View File

@ -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 // without shaders some approximation is needed. This won't look as good
// as the shader version but it's an acceptable compromise. // 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 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); 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); glDepthFunc(GL_LEQUAL);
glColor4f(fc[0], fc[1], fc[2], fogd1); glColor4f(fc[0], fc[1], fc[2], fogd1);
glBegin(GL_TRIANGLE_FAN); 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); 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); glVertex3f(glseg.x1, ztop[0], glseg.y1);
glColor4f(fc[0], fc[1], fc[2], fogd2); 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); 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); glVertex3f(glseg.x2, zbottom[1], glseg.y2);
glEnd(); glEnd();
glDepthFunc(GL_LESS); glDepthFunc(GL_LESS);
@ -733,8 +739,13 @@ void GLFlat::DrawLightsCompat(int pass)
// Sets up the texture coordinates for one light to be rendered // 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 }; 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; Plane p;
FVector3 nearPt, up, right; FVector3 nearPt, up, right;
@ -748,7 +759,7 @@ bool GLWall::PrepareLight(ADynamicLight * light, int pass)
return false; 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; 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; FLightNode * node;
// black fog is diminishing light and should affect lights less than the rest! // 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); if (pass == GLPASS_LIGHTTEX) mDrawer->SetFog((255 + wall->lightlevel) >> 1, 0, NULL, false);
else mDrawer->SetFog(lightlevel, 0, &Colormap, true); else mDrawer->SetFog(wall->lightlevel, 0, &wall->Colormap, true);
if (seg->sidedef == NULL) if (wall->seg->sidedef == NULL)
{ {
return; 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 // 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 // To avoid constant rechecking for polyobjects use the subsector's lightlist instead
node = sub->lighthead; node = wall->sub->lighthead;
} }
else else
{ {
@ -806,7 +817,7 @@ void GLWall::RenderLightsCompat(int pass)
} }
texcoord save[4]; texcoord save[4];
memcpy(save, tcs, sizeof(tcs)); memcpy(save, wall->tcs, sizeof(wall->tcs));
while (node) while (node)
{ {
ADynamicLight * light = node->lightsource; ADynamicLight * light = node->lightsource;
@ -818,15 +829,15 @@ void GLWall::RenderLightsCompat(int pass)
node = node->nextLight; node = node->nextLight;
continue; continue;
} }
if (PrepareLight(light, pass)) if (PrepareLight(wall, light, pass))
{ {
vertcount = 0; wall->vertcount = 0;
RenderWall(RWF_TEXTURED); wall->RenderWall(GLWall::RWF_TEXTURED);
} }
node = node->nextLight; node = node->nextLight;
} }
memcpy(tcs, save, sizeof(tcs)); memcpy(wall->tcs, save, sizeof(wall->tcs));
vertcount = 0; wall->vertcount = 0;
} }
//========================================================================== //==========================================================================

View File

@ -181,8 +181,11 @@ struct FDrawInfo : public HWDrawInfo
void AddMirrorSurface(GLWall *w) override; void AddMirrorSurface(GLWall *w) override;
void ProcessActorsInPortal(FLinePortalSpan *glport) 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 DrawDecal(GLWall *wall, DBaseDecal *decal);
void DoDrawDecals(GLWall *wall); void DoDrawDecals(GLWall *wall);

View File

@ -203,15 +203,11 @@ private:
void PutPortal(HWDrawInfo *di, int ptype); void PutPortal(HWDrawInfo *di, int ptype);
void CheckTexturePosition(FTexCoordInfo *tci); void CheckTexturePosition(FTexCoordInfo *tci);
void RenderFogBoundaryCompat();
void RenderLightsCompat(int pass);
void Put3DWall(HWDrawInfo *di, lightlist_t * lightlist, bool translucent); void Put3DWall(HWDrawInfo *di, lightlist_t * lightlist, bool translucent);
bool SplitWallComplex(HWDrawInfo *di, sector_t * frontsector, bool translucent, float& maplightbottomleft, float& maplightbottomright); bool SplitWallComplex(HWDrawInfo *di, sector_t * frontsector, bool translucent, float& maplightbottomleft, float& maplightbottomright);
void SplitWall(HWDrawInfo *di, sector_t * frontsector, bool translucent); void SplitWall(HWDrawInfo *di, sector_t * frontsector, bool translucent);
void SetupLights(); void SetupLights();
bool PrepareLight(ADynamicLight * light, int pass);
void MakeVertices(bool nosplit); void MakeVertices(bool nosplit);
void RenderWall(int textured); void RenderWall(int textured);
void RenderTextured(int rflags); void RenderTextured(int rflags);

View File

@ -235,7 +235,7 @@ void GLWall::RenderFogBoundary()
} }
else else
{ {
RenderFogBoundaryCompat(); gl_drawinfo->RenderFogBoundaryCompat(this);
} }
} }
} }
@ -450,7 +450,7 @@ void GLWall::Draw(int pass)
case GLPASS_LIGHTTEX: case GLPASS_LIGHTTEX:
case GLPASS_LIGHTTEX_ADDITIVE: case GLPASS_LIGHTTEX_ADDITIVE:
case GLPASS_LIGHTTEX_FOGGY: case GLPASS_LIGHTTEX_FOGGY:
RenderLightsCompat(pass); gl_drawinfo->RenderLightsCompat(this, pass);
break; break;
case GLPASS_TEXONLY: case GLPASS_TEXONLY: