- got rid of the last remaining FMaterial references in the high level renderer.

This commit is contained in:
Christoph Oelckers 2020-04-15 00:36:08 +02:00
parent 4cbd20e822
commit c178313da5
4 changed files with 15 additions and 26 deletions

View file

@ -750,10 +750,12 @@ public:
return wrapped.GetTranslucency();
}
// Since these properties will later piggyback on existing members of FGameTexture, the accessors need to be here.
FGameTexture *GetSkyFace(int num)
{
return reinterpret_cast<FGameTexture*>(isSkybox() ? static_cast<FSkyBox*>(&wrapped)->faces[num] : nullptr);
}
bool GetSkyFlip() { return isSkybox() ? static_cast<FSkyBox*>(&wrapped)->fliptop : false; }
};

View file

@ -114,8 +114,7 @@ void FHWModelRenderer::SetInterpolation(double inter)
void FHWModelRenderer::SetMaterial(FGameTexture *skin, bool clampNoFilter, int translation)
{
FMaterial * tex = FMaterial::ValidateTexture(skin->GetTexture(), false);
state.SetMaterial(tex, clampNoFilter ? CLAMP_NOFILTER : CLAMP_NONE, translation, -1);
state.SetMaterial(skin, false, clampNoFilter ? CLAMP_NOFILTER : CLAMP_NONE, translation, -1);
state.SetLightIndex(modellightindex);
}

View file

@ -94,11 +94,9 @@ void HWSkyPortal::RenderDome(HWDrawInfo *di, FRenderState &state, FGameTexture *
//
//-----------------------------------------------------------------------------
void HWSkyPortal::RenderBox(HWDrawInfo *di, FRenderState &state, FTextureID texno, FGameTexture * gltex, float x_offset, bool sky2)
void HWSkyPortal::RenderBox(HWDrawInfo *di, FRenderState &state, FTextureID texno, FGameTexture * tex, float x_offset, bool sky2)
{
FSkyBox * sb = static_cast<FSkyBox*>(gltex->GetTexture());
int faces;
FMaterial * tex;
state.EnableModelMatrix(true);
state.mModelMatrix.loadIdentity();
@ -108,46 +106,39 @@ void HWSkyPortal::RenderBox(HWDrawInfo *di, FRenderState &state, FTextureID texn
else
state.mModelMatrix.rotate(-180.0f+x_offset, di->Level->info->skyrotatevector2.X, di->Level->info->skyrotatevector2.Z, di->Level->info->skyrotatevector2.Y);
if (sb->faces[5])
if (tex->GetSkyFace(5))
{
faces=4;
// north
tex = FMaterial::ValidateTexture(sb->faces[0], false);
state.SetMaterial(tex, CLAMP_XY, 0, -1);
state.SetMaterial(tex->GetSkyFace(0), false, CLAMP_XY, 0, -1);
state.Draw(DT_TriangleStrip, vertexBuffer->FaceStart(0), 4);
// east
tex = FMaterial::ValidateTexture(sb->faces[1], false);
state.SetMaterial(tex, CLAMP_XY, 0, -1);
state.SetMaterial(tex->GetSkyFace(1), false, CLAMP_XY, 0, -1);
state.Draw(DT_TriangleStrip, vertexBuffer->FaceStart(1), 4);
// south
tex = FMaterial::ValidateTexture(sb->faces[2], false);
state.SetMaterial(tex, CLAMP_XY, 0, -1);
state.SetMaterial(tex->GetSkyFace(2), false, CLAMP_XY, 0, -1);
state.Draw(DT_TriangleStrip, vertexBuffer->FaceStart(2), 4);
// west
tex = FMaterial::ValidateTexture(sb->faces[3], false);
state.SetMaterial(tex, CLAMP_XY, 0, -1);
state.SetMaterial(tex->GetSkyFace(3), false, CLAMP_XY, 0, -1);
state.Draw(DT_TriangleStrip, vertexBuffer->FaceStart(3), 4);
}
else
{
faces=1;
tex = FMaterial::ValidateTexture(sb->faces[0], false);
state.SetMaterial(tex, CLAMP_XY, 0, -1);
state.SetMaterial(tex->GetSkyFace(0), false, CLAMP_XY, 0, -1);
state.Draw(DT_TriangleStrip, vertexBuffer->FaceStart(-1), 10);
}
// top
tex = FMaterial::ValidateTexture(sb->faces[faces], false);
state.SetMaterial(tex, CLAMP_XY, 0, -1);
state.Draw(DT_TriangleStrip, vertexBuffer->FaceStart(sb->fliptop ? 6 : 5), 4);
state.SetMaterial(tex->GetSkyFace(faces), false, CLAMP_XY, 0, -1);
state.Draw(DT_TriangleStrip, vertexBuffer->FaceStart(tex->GetSkyFlip() ? 6 : 5), 4);
// bottom
tex = FMaterial::ValidateTexture(sb->faces[faces+1], false);
state.SetMaterial(tex, CLAMP_XY, 0, -1);
state.SetMaterial(tex->GetSkyFace(faces+1), false, CLAMP_XY, 0, -1);
state.Draw(DT_TriangleStrip, vertexBuffer->FaceStart(4), 4);
state.EnableModelMatrix(false);

View file

@ -162,12 +162,9 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state)
state.AlphaFunc(Alpha_GEqual, 0.f);
if (cmd.mTexture != nullptr)
if (cmd.mTexture != nullptr && cmd.mTexture->isValid())
{
auto mat = FMaterial::ValidateTexture(cmd.mTexture->GetTexture(), false);
if (mat == nullptr) continue;
state.SetMaterial(mat, cmd.mFlags & F2DDrawer::DTF_Wrap ? CLAMP_NONE : CLAMP_XY_NOMIP, cmd.mTranslationId, -1);
state.SetMaterial(cmd.mTexture, false, cmd.mFlags & F2DDrawer::DTF_Wrap ? CLAMP_NONE : CLAMP_XY_NOMIP, cmd.mTranslationId, -1);
state.EnableTexture(true);
// Canvas textures are stored upside down