2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-05-13 20:31:21 +00:00
metaforce/Runtime/CTextureCache.hpp
Phillip Stephens dad7249927
RE COutput/InputStream and friends and migrate over
This branch is probably still horribly broken, but it's a good first step to migrating away from having hecl embedded in the runtime
2022-02-21 08:01:05 -08:00

51 lines
1.2 KiB
C++

#pragma once
#include "Runtime/RetroTypes.hpp"
#include "Runtime/Graphics/CTexture.hpp"
#include <map>
namespace metaforce {
class CPaletteInfo {
u32 m_format;
u32 m_elementCount;
u64 m_dolphinHash;
public:
explicit CPaletteInfo(CInputStream& in)
: m_format(in.ReadLong()), m_elementCount(in.ReadLong()), m_dolphinHash(in.ReadLongLong()) {}
};
class CTextureInfo {
ETexelFormat m_format;
u32 m_mipCount;
u16 m_width;
u16 m_height;
u64 m_dolphinHash;
std::optional<CPaletteInfo> m_paletteInfo;
public:
explicit CTextureInfo(CInputStream& in)
: m_format(ETexelFormat(in.ReadLong()))
, m_mipCount(in.ReadLong())
, m_width(in.ReadShort())
, m_height(in.ReadShort())
, m_dolphinHash(in.ReadLongLong()) {
bool hasPal = in.ReadBool();
if (hasPal)
m_paletteInfo.emplace(in);
}
};
class CTextureCache {
public:
std::map<CAssetId, CTextureInfo> m_textureInfo;
public:
explicit CTextureCache(CInputStream& in);
const CTextureInfo* GetTextureInfo(CAssetId id) const;
};
CFactoryFnReturn FTextureCacheFactory(const metaforce::SObjectTag& tag, CInputStream& in,
const metaforce::CVParamTransfer& vparms, CObjectReference* selfRef);
} // namespace metaforce