- minor FTexture cleanup.

This commit is contained in:
Christoph Oelckers 2020-04-11 18:20:23 +02:00
parent b4e9c3f20d
commit 721b857e5e
14 changed files with 120 additions and 112 deletions

View file

@ -39,6 +39,7 @@
#include "colormatcher.h" #include "colormatcher.h"
#include "templates.h" #include "templates.h"
#include "palettecontainer.h" #include "palettecontainer.h"
#include "files.h"
PaletteContainer GPalette; PaletteContainer GPalette;
FColorMatcher ColorMatcher; FColorMatcher ColorMatcher;
@ -58,18 +59,31 @@ void PaletteContainer::Init(int numslots) // This cannot be a constructor!!!
remap.Inactive = true; remap.Inactive = true;
AddRemap(&remap); AddRemap(&remap);
TranslationTables.Resize(numslots); TranslationTables.Resize(numslots);
ColorMatcher.SetPalette(BaseColors);
} }
void PaletteContainer::SetPalette(const uint8_t* colors) void PaletteContainer::SetPalette(const uint8_t* colors, int transparent_index)
{ {
// At this point we do not care about the transparent index yet.
for (int i = 0; i < 256; i++, colors += 3) for (int i = 0; i < 256; i++, colors += 3)
{ {
BaseColors[i] = PalEntry(colors[0], colors[1], colors[2]); BaseColors[i] = PalEntry(255, colors[0], colors[1], colors[2]);
Remap[i] = i; Remap[i] = i;
} }
uniqueRemaps[0]->MakeIdentity(); // update the identity remap.
if (transparent_index >= 0 && transparent_index <= 255)
{
BaseColors[transparent_index] = 0;
uniqueRemaps[0]->Palette[transparent_index] = 0;
}
uniqueRemaps[0]->crc32 = CalcCRC32((uint8_t*)uniqueRemaps[0]->Palette, sizeof(uniqueRemaps[0]->Palette));
// Find white and black from the original palette so that they can be // Find white and black from the original palette so that they can be
// used to make an educated guess of the translucency % for a BOOM // used to make an educated guess of the translucency % for a
// translucency map. // translucency map.
WhiteIndex = BestColor((uint32_t*)BaseColors, 255, 255, 255, 0, 255); WhiteIndex = BestColor((uint32_t*)BaseColors, 255, 255, 255, 0, 255);
BlackIndex = BestColor((uint32_t*)BaseColors, 0, 0, 0, 0, 255); BlackIndex = BestColor((uint32_t*)BaseColors, 0, 0, 0, 0, 255);
@ -89,6 +103,35 @@ void PaletteContainer::Clear()
TranslationTables.Reset(); TranslationTables.Reset();
} }
//===========================================================================
//
//
//
//===========================================================================
int PaletteContainer::DetermineTranslucency(FileReader& tranmap)
{
uint8_t index;
PalEntry newcolor;
PalEntry newcolor2;
if (!tranmap.isOpen()) return 255;
tranmap.Seek(GPalette.BlackIndex * 256 + GPalette.WhiteIndex, FileReader::SeekSet);
tranmap.Read(&index, 1);
newcolor = GPalette.BaseColors[GPalette.Remap[index]];
tranmap.Seek(GPalette.WhiteIndex * 256 + GPalette.BlackIndex, FileReader::SeekSet);
tranmap.Read(&index, 1);
newcolor2 = GPalette.BaseColors[GPalette.Remap[index]];
if (newcolor2.r == 255) // if black on white results in white it's either
// fully transparent or additive
{
return -newcolor.r;
}
return newcolor.r;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// //
// //
@ -166,7 +209,7 @@ FRemapTable *PaletteContainer::TranslationToTable(int translation)
if (type <= 0 || type >= TranslationTables.Size() || index >= NumTranslations(type)) if (type <= 0 || type >= TranslationTables.Size() || index >= NumTranslations(type))
{ {
return NULL; return uniqueRemaps[0]; // this is the identity table.
} }
return GetTranslation(type, index); return GetTranslation(type, index);
} }
@ -664,10 +707,10 @@ bool FRemapTable::AddToTranslation(const char *range)
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool FRemapTable::AddColors(int start, int count, const uint8_t*colors) bool FRemapTable::AddColors(int start, int count, const uint8_t*colors, int trans_color)
{ {
int end = start + count; int end = start + count;
if (IndexOutOfRange(start, end)) if (IndexOutOfRange(start, end-1))
{ {
return false; return false;
} }
@ -680,7 +723,7 @@ bool FRemapTable::AddColors(int start, int count, const uint8_t*colors)
colors += 3; colors += 3;
int j = GPalette.Remap[i]; int j = GPalette.Remap[i];
Palette[j] = PalEntry(j == 0 ? 0 : 255, br, bg, bb); Palette[j] = PalEntry(j == trans_color ? 0 : 255, br, bg, bb);
Remap[j] = ColorMatcher.Pick(Palette[j]); Remap[j] = ColorMatcher.Pick(Palette[j]);
} }
return true; return true;

View file

@ -4,6 +4,8 @@
#include "memarena.h" #include "memarena.h"
#include "palentry.h" #include "palentry.h"
class FileReader;
struct FRemapTable struct FRemapTable
{ {
FRemapTable(int count = 256) { NumEntries = count; } FRemapTable(int count = 256) { NumEntries = count; }
@ -18,7 +20,7 @@ struct FRemapTable
bool AddColourisation(int start, int end, int r, int g, int b); bool AddColourisation(int start, int end, int r, int g, int b);
bool AddTint(int start, int end, int r, int g, int b, int amount); bool AddTint(int start, int end, int r, int g, int b, int amount);
bool AddToTranslation(const char* range); bool AddToTranslation(const char* range);
bool AddColors(int start, int count, const uint8_t*); bool AddColors(int start, int count, const uint8_t*, int trans_color = 0);
uint8_t Remap[256]; // For the software renderer uint8_t Remap[256]; // For the software renderer
PalEntry Palette[256]; // The ideal palette this maps to PalEntry Palette[256]; // The ideal palette this maps to
@ -79,8 +81,9 @@ private:
TArray<TAutoGrowArray<FRemapTablePtr, FRemapTable*>> TranslationTables; TArray<TAutoGrowArray<FRemapTablePtr, FRemapTable*>> TranslationTables;
public: public:
void Init(int numslots); // This cannot be a constructor!!! void Init(int numslots); // This cannot be a constructor!!!
void SetPalette(const uint8_t* colors); void SetPalette(const uint8_t* colors, int transparent_index = -1);
void Clear(); void Clear();
int DetermineTranslucency(FileReader& file);
FRemapTable* AddRemap(FRemapTable* remap); FRemapTable* AddRemap(FRemapTable* remap);
void UpdateTranslation(int trans, FRemapTable* remap); void UpdateTranslation(int trans, FRemapTable* remap);
int AddTranslation(int slot, FRemapTable* remap, int count = 1); int AddTranslation(int slot, FRemapTable* remap, int count = 1);

View file

@ -51,6 +51,7 @@ public:
FColorMatcher (const uint32_t *palette) { Pal = reinterpret_cast<const PalEntry*>(palette); } FColorMatcher (const uint32_t *palette) { Pal = reinterpret_cast<const PalEntry*>(palette); }
FColorMatcher (const FColorMatcher &other) = default; FColorMatcher (const FColorMatcher &other) = default;
void SetPalette(PalEntry* palette) { Pal = palette; }
void SetPalette (const uint32_t *palette) { Pal = reinterpret_cast<const PalEntry*>(palette); } void SetPalette (const uint32_t *palette) { Pal = reinterpret_cast<const PalEntry*>(palette); }
uint8_t Pick (int r, int g, int b) uint8_t Pick (int r, int g, int b)
{ {

View file

@ -234,7 +234,7 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
for (auto entry : array) for (auto entry : array)
{ {
FTexture *tex = TexMan.GetTexture(entry, false); FTexture *tex = TexMan.GetTexture(entry, false);
if (tex && tex->SourceLump >= 0 && fileSystem.GetFileContainer(tex->SourceLump) <= fileSystem.GetMaxIwadNum() && tex->UseType == ETextureType::MiscPatch) if (tex && tex->GetSourceLump() >= 0 && fileSystem.GetFileContainer(tex->GetSourceLump()) <= fileSystem.GetMaxIwadNum() && tex->GetUseType() == ETextureType::MiscPatch)
{ {
texs[i] = tex; texs[i] = tex;
} }
@ -389,8 +389,8 @@ void FFont::ReadSheetFont(TArray<FolderEntry> &folderdata, int width, int height
if (lump.isValid()) if (lump.isValid())
{ {
auto tex = TexMan.GetTexture(lump); auto tex = TexMan.GetTexture(lump);
int numtex_x = tex->GetWidth() / width; int numtex_x = tex->GetTexelWidth() / width;
int numtex_y = tex->GetHeight() / height; int numtex_y = tex->GetTexelHeight() / height;
int maxinsheet = int(position) + numtex_x * numtex_y - 1; int maxinsheet = int(position) + numtex_x * numtex_y - 1;
if (minchar > position) minchar = int(position); if (minchar > position) minchar = int(position);
if (maxchar < maxinsheet) maxchar = maxinsheet; if (maxchar < maxinsheet) maxchar = maxinsheet;

View file

@ -103,8 +103,8 @@ FTexture * FTexture::CreateTexture(const char *name, int lumpnum, ETextureType u
tex->UseType = usetype; tex->UseType = usetype;
if (usetype == ETextureType::Flat) if (usetype == ETextureType::Flat)
{ {
int w = tex->GetWidth(); int w = tex->GetTexelWidth();
int h = tex->GetHeight(); int h = tex->GetTexelHeight();
// Auto-scale flats with dimensions 128x128 and 256x256. // Auto-scale flats with dimensions 128x128 and 256x256.
// In hindsight, a bad idea, but RandomLag made it sound better than it really is. // In hindsight, a bad idea, but RandomLag made it sound better than it really is.
@ -333,11 +333,11 @@ int FTexture::CheckRealHeight()
{ {
auto pixels = Get8BitPixels(false); auto pixels = Get8BitPixels(false);
for(int h = GetHeight()-1; h>= 0; h--) for(int h = GetTexelHeight()-1; h>= 0; h--)
{ {
for(int w = 0; w < GetWidth(); w++) for(int w = 0; w < GetTexelWidth(); w++)
{ {
if (pixels[h + w * GetHeight()] != 0) if (pixels[h + w * GetTexelHeight()] != 0)
{ {
// Scale maxy before returning it // Scale maxy before returning it
h = int((h * 2) / Scale.Y); h = int((h * 2) / Scale.Y);
@ -423,7 +423,7 @@ void FTexture::CreateDefaultBrightmap()
auto texbuf = Get8BitPixels(false); auto texbuf = Get8BitPixels(false);
const int white = ColorMatcher.Pick(255, 255, 255); const int white = ColorMatcher.Pick(255, 255, 255);
int size = GetWidth() * GetHeight(); int size = GetTexelWidth() * GetTexelHeight();
for (int i = 0; i<size; i++) for (int i = 0; i<size; i++)
{ {
if (TexMan.GlobalBrightmap.Remap[texbuf[i]] == white) if (TexMan.GlobalBrightmap.Remap[texbuf[i]] == white)
@ -693,8 +693,8 @@ FTextureBuffer FTexture::CreateTexBuffer(int translation, int flags)
int exx = !!(flags & CTF_Expand); int exx = !!(flags & CTF_Expand);
W = GetWidth() + 2 * exx; W = GetTexelWidth() + 2 * exx;
H = GetHeight() + 2 * exx; H = GetTexelHeight() + 2 * exx;
if (!checkonly) if (!checkonly)
{ {
@ -885,7 +885,7 @@ void FTexCoordInfo::GetFromTexture(FTexture *tex, float x, float y, bool forcewo
else else
{ {
float scale_x = x * (float)tex->Scale.X; float scale_x = x * (float)tex->Scale.X;
mRenderWidth = xs_CeilToInt(tex->GetWidth() / scale_x); mRenderWidth = xs_CeilToInt(tex->GetTexelWidth() / scale_x);
mScale.X = scale_x; mScale.X = scale_x;
mTempScale.X = x; mTempScale.X = x;
} }
@ -899,7 +899,7 @@ void FTexCoordInfo::GetFromTexture(FTexture *tex, float x, float y, bool forcewo
else else
{ {
float scale_y = y * (float)tex->Scale.Y; float scale_y = y * (float)tex->Scale.Y;
mRenderHeight = xs_CeilToInt(tex->GetHeight() / scale_y); mRenderHeight = xs_CeilToInt(tex->GetTexelHeight() / scale_y);
mScale.Y = scale_y; mScale.Y = scale_y;
mTempScale.Y = y; mTempScale.Y = y;
} }
@ -909,7 +909,7 @@ void FTexCoordInfo::GetFromTexture(FTexture *tex, float x, float y, bool forcewo
mRenderHeight = -mRenderHeight; mRenderHeight = -mRenderHeight;
} }
mWorldPanning = tex->bWorldPanning || forceworldpanning; mWorldPanning = tex->bWorldPanning || forceworldpanning;
mWidth = tex->GetWidth(); mWidth = tex->GetTexelWidth();
} }

View file

@ -278,9 +278,6 @@ struct FTextureBuffer
// Base texture class // Base texture class
class FTexture class FTexture
{ {
// This is initialization code that is allowed to have full access.
friend void R_InitSpriteDefs ();
friend void R_InstallSprite (int num, spriteframewithrotate *sprtemp, int &maxframe);
friend class GLDefsParser; friend class GLDefsParser;
friend class FMultipatchTextureBuilder; friend class FMultipatchTextureBuilder;
@ -302,7 +299,6 @@ class FTexture
friend class FSkyBox; friend class FSkyBox;
friend class FBrightmapTexture; friend class FBrightmapTexture;
friend class FFont; friend class FFont;
friend class FSpecialFont;
public: public:
@ -322,6 +318,9 @@ public:
double GetDisplayLeftOffsetDouble() { return GetScaledLeftOffsetDouble(0); } double GetDisplayLeftOffsetDouble() { return GetScaledLeftOffsetDouble(0); }
double GetDisplayTopOffsetDouble() { return GetScaledTopOffsetDouble(0); } double GetDisplayTopOffsetDouble() { return GetScaledTopOffsetDouble(0); }
int GetTexelWidth() { return Width; }
int GetTexelHeight() { return Height; }
bool isValid() const { return UseType != ETextureType::Null; } bool isValid() const { return UseType != ETextureType::Null; }
bool isSWCanvas() const { return UseType == ETextureType::SWCanvas; } bool isSWCanvas() const { return UseType == ETextureType::SWCanvas; }
@ -352,13 +351,25 @@ public:
void CreateDefaultBrightmap(); void CreateDefaultBrightmap();
bool FindHoles(const unsigned char * buffer, int w, int h); bool FindHoles(const unsigned char * buffer, int w, int h);
void SetUseType(ETextureType type) { UseType = type; } void SetUseType(ETextureType type) { UseType = type; }
int GetSourceLump() const { return SourceLump; }
ETextureType GetUseType() const { return UseType; } ETextureType GetUseType() const { return UseType; }
void CopySize(FTexture* BaseTexture)
{
Width = BaseTexture->GetTexelWidth();
Height = BaseTexture->GetTexelHeight();
_TopOffset[0] = BaseTexture->_TopOffset[0];
_TopOffset[1] = BaseTexture->_TopOffset[1];
_LeftOffset[0] = BaseTexture->_LeftOffset[0];
_LeftOffset[1] = BaseTexture->_LeftOffset[1];
Scale = BaseTexture->Scale;
}
// Returns the whole texture, stored in column-major order // Returns the whole texture, stored in column-major order
virtual TArray<uint8_t> Get8BitPixels(bool alphatex); virtual TArray<uint8_t> Get8BitPixels(bool alphatex);
virtual FBitmap GetBgraBitmap(PalEntry *remap, int *trans = nullptr); virtual FBitmap GetBgraBitmap(PalEntry *remap, int *trans = nullptr);
public:
static bool SmoothEdges(unsigned char * buffer,int w, int h); static bool SmoothEdges(unsigned char * buffer,int w, int h);
static PalEntry averageColor(const uint32_t *data, int size, int maxout); static PalEntry averageColor(const uint32_t *data, int size, int maxout);
@ -441,9 +452,6 @@ protected:
void SetSpeed(float fac) { shaderspeed = fac; } void SetSpeed(float fac) { shaderspeed = fac; }
int GetWidth () { return Width; }
int GetHeight () { return Height; }
int GetScaledWidth () { int foo = int((Width * 2) / Scale.X); return (foo >> 1) + (foo & 1); } int GetScaledWidth () { int foo = int((Width * 2) / Scale.X); return (foo >> 1) + (foo & 1); }
int GetScaledHeight () { int foo = int((Height * 2) / Scale.Y); return (foo >> 1) + (foo & 1); } int GetScaledHeight () { int foo = int((Height * 2) / Scale.Y); return (foo >> 1) + (foo & 1); }
double GetScaledWidthDouble () { return Width / Scale.X; } double GetScaledWidthDouble () { return Width / Scale.X; }
@ -471,17 +479,6 @@ protected:
static void InitGrayMap(); static void InitGrayMap();
void CopySize(FTexture *BaseTexture)
{
Width = BaseTexture->GetWidth();
Height = BaseTexture->GetHeight();
_TopOffset[0] = BaseTexture->_TopOffset[0];
_TopOffset[1] = BaseTexture->_TopOffset[1];
_LeftOffset[0] = BaseTexture->_LeftOffset[0];
_LeftOffset[1] = BaseTexture->_LeftOffset[1];
Scale = BaseTexture->Scale;
}
void SetScaledSize(int fitwidth, int fitheight); void SetScaledSize(int fitwidth, int fitheight);
void SetScale(const DVector2 &scale) void SetScale(const DVector2 &scale)
{ {

View file

@ -2032,52 +2032,6 @@ void MapLoader::LoopSidedefs (bool firstloop)
// //
//=========================================================================== //===========================================================================
int MapLoader::DetermineTranslucency (int lumpnum)
{
auto tranmap = fileSystem.OpenFileReader (lumpnum);
uint8_t index;
PalEntry newcolor;
PalEntry newcolor2;
tranmap.Seek (GPalette.BlackIndex * 256 + GPalette.WhiteIndex, FileReader::SeekSet);
tranmap.Read (&index, 1);
newcolor = GPalette.BaseColors[GPalette.Remap[index]];
tranmap.Seek (GPalette.WhiteIndex * 256 + GPalette.BlackIndex, FileReader::SeekSet);
tranmap.Read (&index, 1);
newcolor2 = GPalette.BaseColors[GPalette.Remap[index]];
if (newcolor2.r == 255) // if black on white results in white it's either
// fully transparent or additive
{
if (developer >= DMSG_NOTIFY)
{
char lumpname[9];
lumpname[8] = 0;
fileSystem.GetFileShortName (lumpname, lumpnum);
Printf ("%s appears to be additive translucency %d (%d%%)\n", lumpname, newcolor.r,
newcolor.r*100/255);
}
return -newcolor.r;
}
if (developer >= DMSG_NOTIFY)
{
char lumpname[9];
lumpname[8] = 0;
fileSystem.GetFileShortName (lumpname, lumpnum);
Printf ("%s appears to be translucency %d (%d%%)\n", lumpname, newcolor.r,
newcolor.r*100/255);
}
return newcolor.r;
}
//===========================================================================
//
//
//
//===========================================================================
void MapLoader::ProcessSideTextures(bool checktranmap, side_t *sd, sector_t *sec, intmapsidedef_t *msd, int special, int tag, short *alpha, FMissingTextureTracker &missingtex) void MapLoader::ProcessSideTextures(bool checktranmap, side_t *sd, sector_t *sec, intmapsidedef_t *msd, int special, int tag, short *alpha, FMissingTextureTracker &missingtex)
{ {
switch (special) switch (special)
@ -2153,7 +2107,18 @@ void MapLoader::ProcessSideTextures(bool checktranmap, side_t *sd, sector_t *sec
else if ((lumpnum = fileSystem.CheckNumForName (msd->midtexture)) > 0 && else if ((lumpnum = fileSystem.CheckNumForName (msd->midtexture)) > 0 &&
fileSystem.FileLength (lumpnum) == 65536) fileSystem.FileLength (lumpnum) == 65536)
{ {
*alpha = (short)DetermineTranslucency (lumpnum); auto fr = fileSystem.OpenFileReader(lumpnum);
*alpha = (short)GPalette.DetermineTranslucency (fr);
if (developer >= DMSG_NOTIFY)
{
char lumpname[9];
lumpname[8] = 0;
fileSystem.GetFileShortName(lumpname, lumpnum);
if (*alpha < 0) Printf("%s appears to be additive translucency %d (%d%%)\n", lumpname, -*alpha, -*alpha * 100 / 255);
else Printf("%s appears to be translucency %d (%d%%)\n", lumpname, *alpha, *alpha * 100 / 255);
}
sd->SetTexture(side_t::mid, FNullTextureID()); sd->SetTexture(side_t::mid, FNullTextureID());
} }
else else

View file

@ -221,7 +221,6 @@ private:
void LoadZSegs(FileReader &data); void LoadZSegs(FileReader &data);
void LoadZNodes(FileReader &data, int glnodes); void LoadZNodes(FileReader &data, int glnodes);
int DetermineTranslucency(int lumpnum);
void SetLineID(int i, line_t *ld); void SetLineID(int i, line_t *ld);
void SaveLineSpecial(line_t *ld); void SaveLineSpecial(line_t *ld);
void FinishLoadingLineDef(line_t *ld, int alpha); void FinishLoadingLineDef(line_t *ld, int alpha);

View file

@ -286,7 +286,7 @@ void R_InstallSprite (int num, spriteframewithrotate *sprtemp, int &maxframe)
{ {
for (int rot = 0; rot < 16; ++rot) for (int rot = 0; rot < 16; ++rot)
{ {
TexMan.GetTexture(sprtemp[frame].Texture[rot])->Rotations = framestart + frame; TexMan.GetTexture(sprtemp[frame].Texture[rot])->SetRotations(framestart + frame);
} }
} }
} }
@ -308,7 +308,7 @@ void R_InstallSprite (int num, spriteframewithrotate *sprtemp, int &maxframe)
// letter/number appended. // letter/number appended.
// The rotation character can be 0 to signify no rotations. // The rotation character can be 0 to signify no rotations.
// //
#define TEX_DWNAME(tex) MAKE_ID(tex->Name[0], tex->Name[1], tex->Name[2], tex->Name[3]) #define TEX_DWNAME(tex) MAKE_ID(tex->GetName()[0], tex->GetName()[1], tex->GetName()[2], tex->GetName()[3])
void R_InitSpriteDefs () void R_InitSpriteDefs ()
{ {
@ -333,7 +333,7 @@ void R_InitSpriteDefs ()
for (i = 0; i < smax; ++i) for (i = 0; i < smax; ++i)
{ {
FTexture *tex = TexMan.ByIndex(i); FTexture *tex = TexMan.ByIndex(i);
if (tex->UseType == ETextureType::Sprite && strlen(tex->Name) >= 6) if (tex->GetUseType() == ETextureType::Sprite && strlen(tex->GetName()) >= 6)
{ {
size_t bucket = TEX_DWNAME(tex) % smax; size_t bucket = TEX_DWNAME(tex) % smax;
hashes[i].Next = hashes[bucket].Head; hashes[i].Next = hashes[bucket].Head;
@ -417,10 +417,10 @@ void R_InitSpriteDefs ()
FTexture *tex = TexMan.GetTexture(hash); FTexture *tex = TexMan.GetTexture(hash);
if (TEX_DWNAME(tex) == intname) if (TEX_DWNAME(tex) == intname)
{ {
bool res = R_InstallSpriteLump (FTextureID(hash), tex->Name[4] - 'A', tex->Name[5], false, sprtemp, maxframe); bool res = R_InstallSpriteLump (FTextureID(hash), tex->GetName()[4] - 'A', tex->GetName()[5], false, sprtemp, maxframe);
if (tex->Name[6] && res) if (tex->GetName()[6] && res)
R_InstallSpriteLump (FTextureID(hash), tex->Name[6] - 'A', tex->Name[7], true, sprtemp, maxframe); R_InstallSpriteLump (FTextureID(hash), tex->GetName()[6] - 'A', tex->GetName()[7], true, sprtemp, maxframe);
} }
hash = hashes[hash].Next; hash = hashes[hash].Next;
} }

View file

@ -337,8 +337,8 @@ bool FHardwareTexture::BindOrCreate(FTexture *tex, int texunit, int clampmode, i
} }
else else
{ {
w = tex->GetWidth(); w = tex->GetTexelWidth();
h = tex->GetHeight(); h = tex->GetTexelHeight();
} }
if (!CreateTexture(texbuffer.mBuffer, w, h, texunit, needmipmap, "FHardwareTexture.BindOrCreate")) if (!CreateTexture(texbuffer.mBuffer, w, h, texunit, needmipmap, "FHardwareTexture.BindOrCreate"))
{ {

View file

@ -199,8 +199,8 @@ FMaterial::FMaterial(FTexture * tx, bool expanded)
} }
} }
} }
mWidth = tx->GetWidth(); mWidth = tx->GetTexelWidth();
mHeight = tx->GetHeight(); mHeight = tx->GetTexelHeight();
mLeftOffset = tx->GetLeftOffset(0); // These only get used by decals and decals should not use renderer-specific offsets. mLeftOffset = tx->GetLeftOffset(0); // These only get used by decals and decals should not use renderer-specific offsets.
mTopOffset = tx->GetTopOffset(0); mTopOffset = tx->GetTopOffset(0);
mRenderWidth = tx->GetScaledWidth(); mRenderWidth = tx->GetScaledWidth();
@ -473,8 +473,8 @@ again:
goto again; goto again;
} }
if (tex->Brightmap != NULL && if (tex->Brightmap != NULL &&
(tex->GetWidth() != tex->Brightmap->GetWidth() || (tex->GetTexelWidth() != tex->Brightmap->GetTexelWidth() ||
tex->GetHeight() != tex->Brightmap->GetHeight()) tex->GetTexelHeight() != tex->Brightmap->GetTexelHeight())
) )
{ {
// do not expand if the brightmap's size differs. // do not expand if the brightmap's size differs.

View file

@ -108,8 +108,8 @@ PolyDepthStencil *PolyHardwareTexture::GetDepthStencil(FTexture *tex)
{ {
if (!mDepthStencil) if (!mDepthStencil)
{ {
int w = tex->GetWidth(); int w = tex->GetTexelWidth();
int h = tex->GetHeight(); int h = tex->GetTexelHeight();
mDepthStencil.reset(new PolyDepthStencil(w, h)); mDepthStencil.reset(new PolyDepthStencil(w, h));
} }
return mDepthStencil.get(); return mDepthStencil.get();
@ -172,8 +172,8 @@ void PolyHardwareTexture::CreateImage(FTexture *tex, int translation, int flags)
} }
else else
{ {
int w = tex->GetWidth(); int w = tex->GetTexelWidth();
int h = tex->GetHeight(); int h = tex->GetTexelHeight();
mCanvas->Resize(w, h, false); mCanvas->Resize(w, h, false);
} }
} }

View file

@ -58,8 +58,8 @@ public:
int GetSkyOffset() const { return mTexture->GetSkyOffset(); } int GetSkyOffset() const { return mTexture->GetSkyOffset(); }
PalEntry GetSkyCapColor(bool bottom) const { return mTexture->GetSkyCapColor(bottom); } PalEntry GetSkyCapColor(bool bottom) const { return mTexture->GetSkyCapColor(bottom); }
int GetWidth () { return mTexture->GetWidth(); } int GetWidth () { return mTexture->GetTexelWidth(); }
int GetHeight () { return mTexture->GetHeight(); } int GetHeight () { return mTexture->GetTexelHeight(); }
int GetWidthBits() { return WidthBits; } int GetWidthBits() { return WidthBits; }
int GetHeightBits() { return HeightBits; } int GetHeightBits() { return HeightBits; }

View file

@ -179,8 +179,8 @@ VkTextureImage *VkHardwareTexture::GetDepthStencil(FTexture *tex)
auto fb = GetVulkanFrameBuffer(); auto fb = GetVulkanFrameBuffer();
VkFormat format = fb->GetBuffers()->SceneDepthStencilFormat; VkFormat format = fb->GetBuffers()->SceneDepthStencilFormat;
int w = tex->GetWidth(); int w = tex->GetTexelWidth();
int h = tex->GetHeight(); int h = tex->GetTexelHeight();
ImageBuilder builder; ImageBuilder builder;
builder.setSize(w, h); builder.setSize(w, h);
@ -215,8 +215,8 @@ void VkHardwareTexture::CreateImage(FTexture *tex, int translation, int flags)
auto fb = GetVulkanFrameBuffer(); auto fb = GetVulkanFrameBuffer();
VkFormat format = VK_FORMAT_R8G8B8A8_UNORM; VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
int w = tex->GetWidth(); int w = tex->GetTexelWidth();
int h = tex->GetHeight(); int h = tex->GetTexelHeight();
ImageBuilder imgbuilder; ImageBuilder imgbuilder;
imgbuilder.setFormat(format); imgbuilder.setFormat(format);