From eb369dbf4161fcf2177f7178492ba9ae85daf8c6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 17 Apr 2020 23:50:30 +0200 Subject: [PATCH] - initialize texture offsets for images on construction. --- src/common/textures/texture.cpp | 24 ++++++++++++++++++++++++ src/common/textures/textures.h | 10 +--------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/common/textures/texture.cpp b/src/common/textures/texture.cpp index eb050ac6c..83e31f00f 100644 --- a/src/common/textures/texture.cpp +++ b/src/common/textures/texture.cpp @@ -983,6 +983,30 @@ FWrapperTexture::FWrapperTexture(int w, int h, int bits) } +FGameTexture::FGameTexture(FTexture* wrap) : Base(wrap) +{ + id.SetInvalid(); + TexelWidth = Base->GetWidth(); + DisplayWidth = (float)TexelWidth; + TexelHeight = Base->GetHeight(); + DisplayHeight = (float)TexelHeight; + auto img = Base->GetImage(); + if (img) + { + auto ofs = img->GetOffsets(); + LeftOffset[0] = LeftOffset[1] = ofs.first; + TopOffset[0] = TopOffset[1] = ofs.second; + } + else + { + LeftOffset[0] = LeftOffset[1] = + TopOffset[0] = TopOffset[1] = 0; + + } + ScaleX = ScaleY = 1.f; +} + + FGameTexture::~FGameTexture() { FGameTexture* link = fileSystem.GetLinkedTexture(GetSourceLump()); diff --git a/src/common/textures/textures.h b/src/common/textures/textures.h index 99bb97e96..a24e3b3c4 100644 --- a/src/common/textures/textures.h +++ b/src/common/textures/textures.h @@ -569,15 +569,7 @@ class FGameTexture FMaterial* Material[4] = { }; public: - FGameTexture(FTexture* wrap) : Base(wrap) - { - id.SetInvalid(); - TexelWidth = Base->GetWidth(); - DisplayWidth = (float)TexelWidth; - TexelHeight = Base->GetHeight(); - DisplayHeight = (float)TexelHeight; - ScaleX = ScaleY = 1.f; - } + FGameTexture(FTexture* wrap); ~FGameTexture(); FTextureID GetID() const { return id; } void SetID(FTextureID newid) { id = newid; } // should only be called by the texture manager