- let FSkybox inherit from FImageTexture to simplify the redirection of the base image for the software renderer.

This commit is contained in:
Christoph Oelckers 2020-04-13 14:23:57 +02:00
parent 9a3b663e04
commit e92be97f33
5 changed files with 30 additions and 56 deletions

View file

@ -54,18 +54,23 @@ FImageTexture::FImageTexture(FImageSource *img, const char *name) noexcept
if (img != nullptr)
{
if (name == nullptr) fileSystem.GetFileShortName(Name, img->LumpNum());
Width = img->GetWidth();
Height = img->GetHeight();
auto offsets = img->GetOffsets();
_LeftOffset[1] = _LeftOffset[0] = offsets.first;
_TopOffset[1] = _TopOffset[0] = offsets.second;
bMasked = img->bMasked;
bTranslucent = img->bTranslucent;
SetFromImage();
}
}
void FImageTexture::SetFromImage()
{
auto img = mImage;
Width = img->GetWidth();
Height = img->GetHeight();
auto offsets = img->GetOffsets();
_LeftOffset[1] = _LeftOffset[0] = offsets.first;
_TopOffset[1] = _TopOffset[0] = offsets.second;
bMasked = img->bMasked;
bTranslucent = img->bTranslucent;
}
//===========================================================================
//
//

View file

@ -35,15 +35,14 @@
//-----------------------------------------------------------------------------
FSkyBox::FSkyBox(const char *name)
: FTexture(name)
: FImageTexture(name)
{
FTextureID texid = TexMan.CheckForTexture(name, ETextureType::Wall);
previous = nullptr;
if (texid.isValid())
{
previous = TexMan.GetTexture(texid);
CopySize(previous);
}
else previous = nullptr;
faces[0]=faces[1]=faces[2]=faces[3]=faces[4]=faces[5] = nullptr;
UseType = ETextureType::Override;
bSkybox = true;
@ -56,29 +55,12 @@ FSkyBox::FSkyBox(const char *name)
//
//-----------------------------------------------------------------------------
TArray<uint8_t> FSkyBox::Get8BitPixels(bool alphatex)
void FSkyBox::SetSize()
{
return previous->Get8BitPixels(alphatex);
}
//-----------------------------------------------------------------------------
//
//
//
//-----------------------------------------------------------------------------
FBitmap FSkyBox::GetBgraBitmap(const PalEntry *p, int *trans)
{
return previous->GetBgraBitmap(p, trans);
}
//-----------------------------------------------------------------------------
//
//
//
//-----------------------------------------------------------------------------
FImageSource *FSkyBox::GetImage() const
{
return previous->GetImage();
if (!previous && faces[0]) previous = faces[0];
if (previous && previous->GetImage())
{
SetImage(previous->GetImage());
SetFromImage();
}
}

View file

@ -8,7 +8,7 @@
//
//-----------------------------------------------------------------------------
class FSkyBox : public FTexture
class FSkyBox : public FImageTexture
{
public:
@ -17,19 +17,7 @@ public:
bool fliptop;
FSkyBox(const char *name);
TArray<uint8_t> Get8BitPixels(bool alphatex);
FBitmap GetBgraBitmap(const PalEntry *, int *trans) override;
FImageSource *GetImage() const override;
void SetSize()
{
if (!previous && faces[0]) previous = faces[0];
if (previous)
{
CopySize(previous);
}
}
void SetSize();
bool Is3Face() const
{

View file

@ -241,8 +241,8 @@ public:
double GetDisplayHeightDouble() { return Height / Scale.Y; }
int GetDisplayLeftOffset() { return GetScaledLeftOffset(0); }
int GetDisplayTopOffset() { return GetScaledTopOffset(0); }
double GetDisplayLeftOffsetDouble() { return GetScaledLeftOffsetDouble(0); }
double GetDisplayTopOffsetDouble() { return GetScaledTopOffsetDouble(0); }
double GetDisplayLeftOffsetDouble(int adjusted = 0) { return _LeftOffset[adjusted] / Scale.X; }
double GetDisplayTopOffsetDouble(int adjusted = 0) { return _TopOffset[adjusted] / Scale.Y; }
int GetTexelWidth() { return Width; }
int GetTexelHeight() { return Height; }
@ -398,8 +398,6 @@ protected:
int GetTopOffset(int adjusted) { return _TopOffset[adjusted]; }
int GetScaledLeftOffset (int adjusted) { int foo = int((_LeftOffset[adjusted] * 2) / Scale.X); return (foo >> 1) + (foo & 1); }
int GetScaledTopOffset (int adjusted) { int foo = int((_TopOffset[adjusted] * 2) / Scale.Y); return (foo >> 1) + (foo & 1); }
double GetScaledLeftOffsetDouble(int adjusted) { return _LeftOffset[adjusted] / Scale.X; }
double GetScaledTopOffsetDouble(int adjusted) { return _TopOffset[adjusted] / Scale.Y; }
// Interfaces for the different renderers. Everything that needs to check renderer-dependent offsets
// should use these, so that if changes are needed, this is the only place to edit.
@ -508,6 +506,9 @@ public:
class FImageTexture : public FTexture
{
FImageSource* mImage;
protected:
FImageTexture(const char *name) : FTexture(name) {}
void SetFromImage();
public:
FImageTexture(FImageSource* image, const char* name = nullptr) noexcept;
virtual TArray<uint8_t> Get8BitPixels(bool alphatex);

View file

@ -73,8 +73,6 @@ public:
int GetTopOffset(int adjusted) { return mTexture->GetTopOffset(adjusted); }
int GetScaledLeftOffset (int adjusted) { return mTexture->GetScaledLeftOffset(adjusted); }
int GetScaledTopOffset (int adjusted) { return mTexture->GetScaledTopOffset(adjusted); }
double GetScaledLeftOffsetDouble(int adjusted) { return mTexture->GetScaledLeftOffsetDouble(adjusted); }
double GetScaledTopOffsetDouble(int adjusted) { return mTexture->GetScaledTopOffsetDouble(adjusted); }
// Interfaces for the different renderers. Everything that needs to check renderer-dependent offsets
// should use these, so that if changes are needed, this is the only place to edit.