From b5077994787eca335dd29409b3da68348c52a821 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Wed, 11 Dec 2019 00:37:30 -0800 Subject: [PATCH] Add texture info lookup --- Runtime/Graphics/CTexture.hpp | 2 +- Runtime/Graphics/CTextureBoo.cpp | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Runtime/Graphics/CTexture.hpp b/Runtime/Graphics/CTexture.hpp index fc0569cc6..ded69b7a1 100644 --- a/Runtime/Graphics/CTexture.hpp +++ b/Runtime/Graphics/CTexture.hpp @@ -59,7 +59,7 @@ private: public: CTexture(ETexelFormat, s16, s16, s32); - CTexture(std::unique_ptr&& in, u32 length, bool otex); + CTexture(std::unique_ptr&& in, u32 length, bool otex, const CTextureInfo* inf); enum class EClampMode { None, One }; ETexelFormat GetTexelFormat() const { return x0_fmt; } ETexelFormat GetMemoryCardTexelFormat() const { diff --git a/Runtime/Graphics/CTextureBoo.cpp b/Runtime/Graphics/CTextureBoo.cpp index 3ba2646ac..1f640c191 100644 --- a/Runtime/Graphics/CTextureBoo.cpp +++ b/Runtime/Graphics/CTextureBoo.cpp @@ -1,8 +1,10 @@ -#include "CTexture.hpp" -#include "CSimplePool.hpp" -#include "CToken.hpp" -#include "Graphics/CGraphics.hpp" +#include "Runtime/Graphics/CTexture.hpp" + +#include "Runtime/CSimplePool.hpp" +#include "Runtime/CToken.hpp" +#include "Runtime/Graphics/CGraphics.hpp" #include "Runtime/CTextureCache.hpp" +#include "Runtime/GameGlobalObjects.hpp" namespace urde { static logvisor::Module Log("urde::CTextureBoo"); @@ -691,7 +693,7 @@ void CTexture::BuildDXT3(const void* data, size_t length) { CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) { m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::DXT3, boo::TextureClampMode::Repeat, data, length) - .get(); + .get(); return true; } BooTrace); } @@ -704,7 +706,8 @@ CTexture::CTexture(ETexelFormat fmt, s16 w, s16 h, s32 mips) : x0_fmt(fmt), x4_w */ } -CTexture::CTexture(std::unique_ptr&& in, u32 length, bool otex) { +CTexture::CTexture(std::unique_ptr&& in, u32 length, bool otex, const CTextureInfo* inf) { + m_textureInfo = inf; std::unique_ptr owned = std::move(in); athena::io::MemoryReader r(owned.get(), length); x0_fmt = ETexelFormat(r.readUint32Big()); @@ -864,7 +867,9 @@ const boo::ObjToken& CTexture::GetFontTexture(EFontType tp) { CFactoryFnReturn FTextureFactory(const urde::SObjectTag& tag, std::unique_ptr&& in, u32 len, const urde::CVParamTransfer& vparms, CObjectReference* selfRef) { u32 u32Owned = vparms.GetOwnedObj(); - return TToken::GetIObjObjectFor(std::make_unique(std::move(in), len, u32Owned == SBIG('OTEX'))); + const CTextureInfo* inf = g_TextureCache->GetTextureInfo(tag.id); + return TToken::GetIObjObjectFor( + std::make_unique(std::move(in), len, u32Owned == SBIG('OTEX'), inf)); } } // namespace urde