mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-23 04:22:34 +00:00
- let FSkybox inherit from FImageTexture to simplify the redirection of the base image for the software renderer.
This commit is contained in:
parent
9a3b663e04
commit
e92be97f33
5 changed files with 30 additions and 56 deletions
|
@ -54,6 +54,13 @@ FImageTexture::FImageTexture(FImageSource *img, const char *name) noexcept
|
|||
if (img != nullptr)
|
||||
{
|
||||
if (name == nullptr) fileSystem.GetFileShortName(Name, img->LumpNum());
|
||||
SetFromImage();
|
||||
}
|
||||
}
|
||||
|
||||
void FImageTexture::SetFromImage()
|
||||
{
|
||||
auto img = mImage;
|
||||
Width = img->GetWidth();
|
||||
Height = img->GetHeight();
|
||||
|
||||
|
@ -64,8 +71,6 @@ FImageTexture::FImageTexture(FImageSource *img, const char *name) noexcept
|
|||
bMasked = img->bMasked;
|
||||
bTranslucent = img->bTranslucent;
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
//
|
||||
|
|
|
@ -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)
|
||||
if (!previous && faces[0]) previous = faces[0];
|
||||
if (previous && previous->GetImage())
|
||||
{
|
||||
return previous->GetBgraBitmap(p, trans);
|
||||
SetImage(previous->GetImage());
|
||||
SetFromImage();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
FImageSource *FSkyBox::GetImage() const
|
||||
{
|
||||
return previous->GetImage();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue