mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-25 05:31:00 +00:00
- moved the offsets to FGameTexture.
# Conflicts: # src/common/textures/textures.h
This commit is contained in:
parent
8843761bf8
commit
61380fc505
6 changed files with 37 additions and 74 deletions
|
@ -290,7 +290,7 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
|
|||
if ((int)position < minchar) minchar = (int)position;
|
||||
if ((int)position > maxchar) maxchar = (int)position;
|
||||
auto tex = TexMan.GetGameTexture(lump);
|
||||
tex->SetScale(Scale);
|
||||
tex->SetScale((float)Scale.X, (float)Scale.Y);
|
||||
charMap.Insert((int)position, tex);
|
||||
Type = Folder;
|
||||
}
|
||||
|
@ -412,17 +412,15 @@ void FFont::ReadSheetFont(TArray<FolderEntry> &folderdata, int width, int height
|
|||
FMultiPatchTexture *image = new FMultiPatchTexture(width, height, part, false, false);
|
||||
FImageTexture *tex = new FImageTexture(image, "");
|
||||
tex->bMultiPatch = true;
|
||||
tex->_LeftOffset[0] =
|
||||
tex->_LeftOffset[1] =
|
||||
tex->_TopOffset[0] =
|
||||
tex->_TopOffset[1] = 0;
|
||||
tex->Scale = Scale;
|
||||
tex->bMasked = true;
|
||||
tex->bTranslucent = -1;
|
||||
tex->bWorldPanning = true;
|
||||
tex->bNoDecals = false;
|
||||
tex->SourceLump = -1; // We do not really care.
|
||||
auto gtex = MakeGameTexture(tex, ETextureType::FontChar);
|
||||
gtex->SetOffsets(0, 0, 0);
|
||||
gtex->SetOffsets(1, 0, 0);
|
||||
gtex->SetScale((float)Scale.X, (float)Scale.Y);
|
||||
TexMan.AddGameTexture(gtex);
|
||||
charMap.Insert(int(position) + x + y * numtex_x, gtex);
|
||||
}
|
||||
|
|
|
@ -64,10 +64,6 @@ void FImageTexture::SetFromImage()
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -140,18 +140,17 @@ void FMultipatchTextureBuilder::MakeTexture(BuildInfo &buildinfo, ETextureType u
|
|||
FImageTexture *tex = new FImageTexture(nullptr, buildinfo.Name);
|
||||
tex->bMultiPatch = true;
|
||||
tex->SetSize(buildinfo.Width, buildinfo.Height);
|
||||
tex->_LeftOffset[0] = buildinfo.LeftOffset[0];
|
||||
tex->_LeftOffset[1] = buildinfo.LeftOffset[1];
|
||||
tex->_TopOffset[0] = buildinfo.TopOffset[0];
|
||||
tex->_TopOffset[1] = buildinfo.TopOffset[1];
|
||||
tex->Scale = buildinfo.Scale;
|
||||
tex->bMasked = true; // we do not really know yet.
|
||||
tex->bTranslucent = -1;
|
||||
tex->bWorldPanning = buildinfo.bWorldPanning;
|
||||
tex->bNoDecals = buildinfo.bNoDecals;
|
||||
tex->SourceLump = buildinfo.DefinitionLump;
|
||||
buildinfo.itex = tex;
|
||||
buildinfo.texture = MakeGameTexture(tex, usetype);
|
||||
buildinfo.texture->SetOffsets(0, buildinfo.LeftOffset[0], buildinfo.TopOffset[0]);
|
||||
buildinfo.texture->SetOffsets(1, buildinfo.LeftOffset[1], buildinfo.TopOffset[1]);
|
||||
buildinfo.texture->SetScale((float)buildinfo.Scale.X, (float)buildinfo.Scale.X);
|
||||
buildinfo.texture->SetWorldPanning(buildinfo.bWorldPanning);
|
||||
|
||||
TexMan.AddGameTexture(buildinfo.texture);
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,6 @@ FTexture::FTexture (const char *name, int lumpnum)
|
|||
bTranslucent = -1;
|
||||
|
||||
|
||||
_LeftOffset[0] = _LeftOffset[1] = _TopOffset[0] = _TopOffset[1] = 0;
|
||||
if (name != NULL)
|
||||
{
|
||||
Name = name;
|
||||
|
@ -795,11 +794,11 @@ void FGameTexture::SetSpriteRect()
|
|||
{
|
||||
|
||||
if (!spi) return;
|
||||
auto leftOffset = GetLeftOffsetHW();
|
||||
auto topOffset = GetTopOffsetHW();
|
||||
auto leftOffset = GetTexelLeftOffset(r_spriteadjustHW);
|
||||
auto topOffset = GetTexelTopOffset(r_spriteadjustHW);
|
||||
|
||||
float fxScale = (float)Base->Scale.X;
|
||||
float fyScale = (float)Base->Scale.Y;
|
||||
float fxScale = GetScaleX();
|
||||
float fyScale = GetScaleY();
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
|
|
|
@ -435,12 +435,12 @@ FTextureID FTextureManager::CreateTexture (int lumpnum, ETextureType usetype)
|
|||
// Now we're stuck with this stupid behaviour.
|
||||
if (w == 128 && h == 128)
|
||||
{
|
||||
out->SetScale(DVector2(2, 2));
|
||||
out->SetScale(2, 2);
|
||||
out->SetWorldPanning(true);
|
||||
}
|
||||
else if (w == 256 && h == 256)
|
||||
{
|
||||
out->SetScale(DVector2(4, 4));
|
||||
out->SetScale(4, 4);
|
||||
out->SetWorldPanning(true);
|
||||
}
|
||||
}
|
||||
|
@ -600,12 +600,10 @@ void FTextureManager::AddHiresTextures (int wadnum)
|
|||
auto oldtex = Textures[tlist[i].GetIndex()].Texture;
|
||||
|
||||
// Replace the entire texture and adjust the scaling and offset factors.
|
||||
newtex->_LeftOffset[0] = int(oldtex->GetDisplayLeftOffset(0) * newtex->Scale.X);
|
||||
newtex->_LeftOffset[1] = int(oldtex->GetDisplayLeftOffset(1) * newtex->Scale.X);
|
||||
newtex->_TopOffset[0] = int(oldtex->GetDisplayTopOffset(0) * newtex->Scale.Y);
|
||||
newtex->_TopOffset[1] = int(oldtex->GetDisplayTopOffset(1) * newtex->Scale.Y);
|
||||
auto gtex = MakeGameTexture(newtex, ETextureType::Override);
|
||||
gtex->SetWorldPanning(true);
|
||||
gtex->SetOffsets(0, xs_RoundToInt(oldtex->GetDisplayLeftOffset(0) * newtex->Scale.X), xs_RoundToInt(oldtex->GetDisplayTopOffset(0) * newtex->Scale.Y));
|
||||
gtex->SetOffsets(1, xs_RoundToInt(oldtex->GetDisplayLeftOffset(1) * newtex->Scale.X), xs_RoundToInt(oldtex->GetDisplayTopOffset(1) * newtex->Scale.Y));
|
||||
gtex->SetDisplaySize(oldtex->GetDisplayWidth(), oldtex->GetDisplayHeight());
|
||||
ReplaceTexture(tlist[i], gtex, true);
|
||||
}
|
||||
|
@ -698,12 +696,10 @@ void FTextureManager::ParseTextureDef(int lump, FMultipatchTextureBuilder &build
|
|||
if (newtex != NULL)
|
||||
{
|
||||
// Replace the entire texture and adjust the scaling and offset factors.
|
||||
newtex->_LeftOffset[0] = int(oldtex->GetDisplayLeftOffset(0) * newtex->Scale.X);
|
||||
newtex->_LeftOffset[1] = int(oldtex->GetDisplayLeftOffset(1) * newtex->Scale.X);
|
||||
newtex->_TopOffset[0] = int(oldtex->GetDisplayTopOffset(0) * newtex->Scale.Y);
|
||||
newtex->_TopOffset[1] = int(oldtex->GetDisplayTopOffset(1) * newtex->Scale.Y);
|
||||
auto gtex = MakeGameTexture(newtex, ETextureType::Override);
|
||||
gtex->SetWorldPanning(true);
|
||||
gtex->SetOffsets(0, xs_RoundToInt(oldtex->GetDisplayLeftOffset(0) * newtex->Scale.X), xs_RoundToInt(oldtex->GetDisplayTopOffset(0) * newtex->Scale.Y));
|
||||
gtex->SetOffsets(1, xs_RoundToInt(oldtex->GetDisplayLeftOffset(1) * newtex->Scale.X), xs_RoundToInt(oldtex->GetDisplayTopOffset(1) * newtex->Scale.Y));
|
||||
gtex->SetDisplaySize(oldtex->GetDisplayWidth(), oldtex->GetDisplayHeight());
|
||||
ReplaceTexture(tlist[i], gtex, true);
|
||||
}
|
||||
|
@ -1471,8 +1467,7 @@ void FTextureManager::AdjustSpriteOffsets()
|
|||
memcpy(&sprid, tex->GetName().GetChars(), 4);
|
||||
if (donotprocess.CheckKey(sprid)) continue; // do not alter sprites that only get partially replaced.
|
||||
}
|
||||
tex->GetTexture()->_LeftOffset[1] = x;
|
||||
tex->GetTexture()->_TopOffset[1] = y;
|
||||
tex->SetOffsets(1, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -255,17 +255,8 @@ public:
|
|||
void CreateUpsampledTextureBuffer(FTextureBuffer &texbuffer, bool hasAlpha, bool checkonly);
|
||||
void CleanHardwareTextures(bool reallyclean);
|
||||
|
||||
// These are mainly meant for 2D code which only needs logical information about the texture to position it properly.
|
||||
int GetDisplayLeftOffset() { return GetScaledLeftOffset(0); }
|
||||
int GetDisplayTopOffset() { return GetScaledTopOffset(0); }
|
||||
double GetDisplayLeftOffsetDouble(int adjusted = 0) { return _LeftOffset[adjusted] / Scale.X; }
|
||||
double GetDisplayTopOffsetDouble(int adjusted = 0) { return _TopOffset[adjusted] / Scale.Y; }
|
||||
|
||||
int GetWidth() { return Width; }
|
||||
int GetHeight() { return Height; }
|
||||
int GetTexelLeftOffset(int adjusted) { return _LeftOffset[adjusted]; }
|
||||
int GetTexelTopOffset(int adjusted) { return _TopOffset[adjusted]; }
|
||||
|
||||
|
||||
bool isSkybox() const { return bSkybox; }
|
||||
bool isFullbrightDisabled() const { return bDisableFullbright; }
|
||||
|
@ -302,10 +293,6 @@ public:
|
|||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -376,25 +363,6 @@ protected:
|
|||
float shaderspeed = 1.f;
|
||||
int shaderindex = 0;
|
||||
|
||||
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); }
|
||||
double GetScaledWidthDouble () { return Width / Scale.X; }
|
||||
double GetScaledHeightDouble () { return Height / Scale.Y; }
|
||||
double GetScaleY() const { return Scale.Y; }
|
||||
|
||||
// Now with improved offset adjustment.
|
||||
int GetLeftOffset(int adjusted) { return _LeftOffset[adjusted]; }
|
||||
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); }
|
||||
|
||||
// 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.
|
||||
|
||||
// For the hardware renderer. The software renderer's have been offloaded to FSoftwareTexture
|
||||
int GetLeftOffsetHW() { return _LeftOffset[r_spriteadjustHW]; }
|
||||
int GetTopOffsetHW() { return _TopOffset[r_spriteadjustHW]; }
|
||||
|
||||
virtual void ResolvePatches() {}
|
||||
|
||||
public:
|
||||
|
@ -405,7 +373,6 @@ public:
|
|||
|
||||
protected:
|
||||
uint16_t Width, Height;
|
||||
int16_t _LeftOffset[2], _TopOffset[2];
|
||||
|
||||
FTexture (const char *name = NULL, int lumpnum = -1);
|
||||
|
||||
|
@ -590,6 +557,7 @@ class FGameTexture
|
|||
FTextureID id;
|
||||
|
||||
uint16_t TexelWidth, TexelHeight;
|
||||
int16_t LeftOffset[2], TopOffset[2];
|
||||
float DisplayWidth, DisplayHeight;
|
||||
float ScaleX, ScaleY;
|
||||
|
||||
|
@ -635,13 +603,10 @@ public:
|
|||
int GetSourceLump() const { return Base->GetSourceLump(); }
|
||||
void SetBrightmap(FGameTexture* tex) { Brightmap = tex->GetTexture(); }
|
||||
|
||||
int GetTexelLeftOffset(int adjusted = 0) /*const*/ { return Base->GetTexelLeftOffset(adjusted); }
|
||||
int GetTexelTopOffset(int adjusted = 0) /*const*/ { return Base->GetTexelTopOffset(adjusted); }
|
||||
double GetDisplayLeftOffset(int adjusted = 0) /*const*/ { return Base->GetDisplayLeftOffsetDouble(adjusted); }
|
||||
double GetDisplayTopOffset(int adjusted = 0) /*const*/ { return Base->GetDisplayTopOffsetDouble(adjusted); }
|
||||
// For the hardware renderer. The software renderer's have been offloaded to FSoftwareTexture
|
||||
int GetLeftOffsetHW() { return GetTexelLeftOffset(r_spriteadjustHW); }
|
||||
int GetTopOffsetHW() { return GetTexelTopOffset(r_spriteadjustHW); }
|
||||
int GetTexelLeftOffset(int adjusted = 0) const { return LeftOffset[adjusted]; }
|
||||
int GetTexelTopOffset(int adjusted = 0) const { return TopOffset[adjusted]; }
|
||||
float GetDisplayLeftOffset(int adjusted = 0) const { return LeftOffset[adjusted] / ScaleX; }
|
||||
float GetDisplayTopOffset(int adjusted = 0) const { return TopOffset[adjusted] / ScaleY; }
|
||||
|
||||
bool isValid() const { return UseType != ETextureType::Null; }
|
||||
int isWarped() { return Base->isWarped(); }
|
||||
|
@ -667,7 +632,6 @@ public:
|
|||
void SetRotations(int index) { Base->SetRotations(index); }
|
||||
void SetSkyOffset(int ofs) { Base->SetSkyOffset(ofs); }
|
||||
int GetSkyOffset() const { return Base->GetSkyOffset(); }
|
||||
void SetScale(DVector2 vec) { Base->SetScale(vec); }
|
||||
|
||||
ISoftwareTexture* GetSoftwareTexture()
|
||||
{
|
||||
|
@ -737,6 +701,18 @@ public:
|
|||
ScaleX = w / TexelWidth;
|
||||
ScaleY = h / TexelHeight;
|
||||
}
|
||||
void SetOffsets(int which, int x, int y)
|
||||
{
|
||||
LeftOffset[which] = x;
|
||||
TopOffset[which] = y;
|
||||
}
|
||||
void SetScale(float x, float y)
|
||||
{
|
||||
ScaleX = x;
|
||||
ScaleY = y;
|
||||
DisplayWidth = x * TexelWidth;
|
||||
DisplayHeight = y * TexelHeight;
|
||||
}
|
||||
|
||||
const SpritePositioningInfo& GetSpritePositioning(int which) { if (spi == nullptr) SetupSpriteData(); return spi[which]; }
|
||||
int GetAreas(FloatRect** pAreas) const { return Base->GetAreas(pAreas); }
|
||||
|
|
Loading…
Reference in a new issue