- use FGameTexture in the model rendering code.

This commit is contained in:
Christoph Oelckers 2020-04-14 18:02:48 +02:00
parent b9b6a354c7
commit 54f4267597
13 changed files with 28 additions and 27 deletions

View file

@ -601,6 +601,7 @@ public:
ETextureType GetUseType() const { return wrapped.GetUseType(); }
float GetShaderSpeed() const { return wrapped.GetShaderSpeed(); }
uint16_t GetRotations() const { return wrapped.GetRotations(); }
void SetRotations(int index) { wrapped.SetRotations(index); }
int GetSkyOffset() const { return wrapped.GetSkyOffset(); }
FTextureID GetID() const { return wrapped.GetID(); }
ISoftwareTexture* GetSoftwareTexture() { return wrapped.GetSoftwareTexture(); }

View file

@ -269,7 +269,7 @@ void FModelRenderer::RenderFrameModels(FLevelLocals *Level, const FSpriteModelFr
if (smf->modelIDs[i] != -1)
{
FModel * mdl = Models[smf->modelIDs[i]];
FTexture *tex = smf->skinIDs[i].isValid() ? TexMan.GetTexture(smf->skinIDs[i], true) : nullptr;
auto tex = smf->skinIDs[i].isValid() ? TexMan.GetGameTexture(smf->skinIDs[i], true) : nullptr;
mdl->BuildVertexBuffer(this);
mdl->PushSpriteMDLFrame(smf, i);

View file

@ -77,7 +77,7 @@ public:
virtual void EndDrawHUDModel(AActor *actor) = 0;
virtual void SetInterpolation(double interpolation) = 0;
virtual void SetMaterial(FTexture *skin, bool clampNoFilter, int translation) = 0;
virtual void SetMaterial(FGameTexture *skin, bool clampNoFilter, int translation) = 0;
virtual void DrawArrays(int start, int count) = 0;
virtual void DrawElements(int numIndices, size_t offset) = 0;
@ -136,7 +136,7 @@ public:
virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length) = 0;
virtual int FindFrame(const char * name) = 0;
virtual void RenderFrame(FModelRenderer *renderer, FTexture * skin, int frame, int frame2, double inter, int translation=0) = 0;
virtual void RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, int translation=0) = 0;
virtual void BuildVertexBuffer(FModelRenderer *renderer) = 0;
virtual void AddSkins(uint8_t *hitlist) = 0;
virtual float getAspectFactor(FLevelLocals *) { return 1.f; }
@ -263,7 +263,7 @@ public:
virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length);
virtual int FindFrame(const char * name);
virtual void RenderFrame(FModelRenderer *renderer, FTexture * skin, int frame, int frame2, double inter, int translation=0);
virtual void RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, int translation=0);
virtual void LoadGeometry();
virtual void AddSkins(uint8_t *hitlist);
@ -349,7 +349,7 @@ public:
virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length);
virtual int FindFrame(const char * name);
virtual void RenderFrame(FModelRenderer *renderer, FTexture * skin, int frame, int frame2, double inter, int translation=0);
virtual void RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, int translation=0);
void LoadGeometry();
void BuildVertexBuffer(FModelRenderer *renderer);
virtual void AddSkins(uint8_t *hitlist);
@ -404,7 +404,7 @@ public:
bool Load(const char * fn, int lumpnum, const char * buffer, int length);
void Initialize();
virtual int FindFrame(const char * name);
virtual void RenderFrame(FModelRenderer *renderer, FTexture * skin, int frame, int frame2, double inter, int translation=0);
virtual void RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, int translation=0);
virtual void AddSkins(uint8_t *hitlist);
FTextureID GetPaletteTexture() const { return mPalette; }
void BuildVertexBuffer(FModelRenderer *renderer);

View file

@ -358,14 +358,14 @@ int FDMDModel::FindFrame(const char * name)
//
//===========================================================================
void FDMDModel::RenderFrame(FModelRenderer *renderer, FTexture * skin, int frameno, int frameno2, double inter, int translation)
void FDMDModel::RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frameno, int frameno2, double inter, int translation)
{
if (frameno >= info.numFrames || frameno2 >= info.numFrames) return;
if (!skin)
{
if (info.numSkins == 0 || !skins[0].isValid()) return;
skin = TexMan.GetTexture(skins[0], true);
skin = TexMan.GetGameTexture(skins[0], true);
if (!skin) return;
}

View file

@ -342,7 +342,7 @@ int FMD3Model::FindFrame(const char * name)
//
//===========================================================================
void FMD3Model::RenderFrame(FModelRenderer *renderer, FTexture * skin, int frameno, int frameno2, double inter, int translation)
void FMD3Model::RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frameno, int frameno2, double inter, int translation)
{
if ((unsigned)frameno >= Frames.Size() || (unsigned)frameno2 >= Frames.Size()) return;
@ -353,16 +353,16 @@ void FMD3Model::RenderFrame(FModelRenderer *renderer, FTexture * skin, int frame
// [BB] In case no skin is specified via MODELDEF, check if the MD3 has a skin for the current surface.
// Note: Each surface may have a different skin.
FTexture *surfaceSkin = skin;
FGameTexture *surfaceSkin = skin;
if (!surfaceSkin)
{
if (curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i].isValid())
{
surfaceSkin = TexMan.GetTexture(curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i], true);
surfaceSkin = TexMan.GetGameTexture(curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i], true);
}
else if (surf->numSkins > 0 && surf->Skins[0].isValid())
{
surfaceSkin = TexMan.GetTexture(surf->Skins[0], true);
surfaceSkin = TexMan.GetGameTexture(surf->Skins[0], true);
}
if (!surfaceSkin)

View file

@ -626,22 +626,22 @@ int FOBJModel::FindFrame(const char* name)
* @param inter Unused
* @param translation The translation for the skin
*/
void FOBJModel::RenderFrame(FModelRenderer *renderer, FTexture * skin, int frameno, int frameno2, double inter, int translation)
void FOBJModel::RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frameno, int frameno2, double inter, int translation)
{
for (unsigned int i = 0; i < surfaces.Size(); i++)
{
OBJSurface *surf = &surfaces[i];
FTexture *userSkin = skin;
FGameTexture *userSkin = skin;
if (!userSkin)
{
if (i < MD3_MAX_SURFACES && curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i].isValid())
{
userSkin = TexMan.GetTexture(curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i], true);
userSkin = TexMan.GetGameTexture(curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i], true);
}
else if (surf->skin.isValid())
{
userSkin = TexMan.GetTexture(surf->skin, true);
userSkin = TexMan.GetGameTexture(surf->skin, true);
}
}

View file

@ -96,7 +96,7 @@ public:
~FOBJModel();
bool Load(const char* fn, int lumpnum, const char* buffer, int length) override;
int FindFrame(const char* name) override;
void RenderFrame(FModelRenderer* renderer, FTexture* skin, int frame, int frame2, double inter, int translation=0) override;
void RenderFrame(FModelRenderer* renderer, FGameTexture* skin, int frame, int frame2, double inter, int translation=0) override;
void BuildVertexBuffer(FModelRenderer* renderer) override;
void AddSkins(uint8_t* hitlist) override;
};

View file

@ -216,7 +216,7 @@ int FUE1Model::FindFrame( const char *name )
return -1;
}
void FUE1Model::RenderFrame( FModelRenderer *renderer, FTexture *skin, int frame, int frame2, double inter, int translation )
void FUE1Model::RenderFrame( FModelRenderer *renderer, FGameTexture *skin, int frame, int frame2, double inter, int translation )
{
// the moment of magic
if ( (frame >= numFrames) || (frame2 >= numFrames) ) return;
@ -232,11 +232,11 @@ void FUE1Model::RenderFrame( FModelRenderer *renderer, FTexture *skin, int frame
vofs += vsize;
continue;
}
FTexture *sskin = skin;
FGameTexture *sskin = skin;
if ( !sskin )
{
if ( curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][groups[i].texNum].isValid() )
sskin = TexMan.GetTexture(curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][groups[i].texNum], true);
sskin = TexMan.GetGameTexture(curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][groups[i].texNum], true);
if ( !sskin )
{
vofs += vsize;

View file

@ -24,7 +24,7 @@ public:
bool Load(const char * fn, int lumpnum, const char * buffer, int length) override;
int FindFrame(const char * name) override;
void RenderFrame(FModelRenderer *renderer, FTexture * skin, int frame, int frame2, double inter, int translation=0) override;
void RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, int translation=0) override;
void BuildVertexBuffer(FModelRenderer *renderer) override;
void AddSkins(uint8_t *hitlist) override;
void LoadGeometry();

View file

@ -395,7 +395,7 @@ float FVoxelModel::getAspectFactor(FLevelLocals *Level)
//
//===========================================================================
void FVoxelModel::RenderFrame(FModelRenderer *renderer, FTexture * skin, int frame, int frame2, double inter, int translation)
void FVoxelModel::RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, int translation)
{
renderer->SetMaterial(skin, true, translation);
GetVertexBuffer(renderer)->SetupFrame(renderer, 0, 0, 0);

View file

@ -123,7 +123,7 @@ static bool R_InstallSpriteLump (FTextureID lump, unsigned frame, char rot, bool
if (frame >= MAX_SPRITE_FRAMES || rotation > 16)
{
Printf (TEXTCOLOR_RED "R_InstallSpriteLump: Bad frame characters in lump %s\n", TexMan.GetTexture(lump)->GetName().GetChars());
Printf (TEXTCOLOR_RED "R_InstallSpriteLump: Bad frame characters in lump %s\n", TexMan.GetGameTexture(lump)->GetName().GetChars());
return false;
}
@ -287,7 +287,7 @@ void R_InstallSprite (int num, spriteframewithrotate *sprtemp, int &maxframe)
{
for (int rot = 0; rot < 16; ++rot)
{
TexMan.GetTexture(sprtemp[frame].Texture[rot])->SetRotations(framestart + frame);
TexMan.GetGameTexture(sprtemp[frame].Texture[rot])->SetRotations(framestart + frame);
}
}
}

View file

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

View file

@ -68,7 +68,7 @@ public:
void BeginDrawHUDModel(AActor *actor, const VSMatrix &objectToWorldMatrix, bool mirrored) override;
void EndDrawHUDModel(AActor *actor) override;
void SetInterpolation(double interpolation) override;
void SetMaterial(FTexture *skin, bool clampNoFilter, int translation) override;
void SetMaterial(FGameTexture *skin, bool clampNoFilter, int translation) override;
void DrawArrays(int start, int count) override;
void DrawElements(int numIndices, size_t offset) override;
};