metaforce/Runtime/Graphics/CTexture.hpp

80 lines
2.9 KiB
C++
Raw Normal View History

2018-10-07 03:42:33 +00:00
#pragma once
#include "GCNTypes.hpp"
2016-03-31 00:38:03 +00:00
#include "CFactoryMgr.hpp"
2016-02-16 05:50:41 +00:00
#include "IObj.hpp"
#include "IOStreams.hpp"
2016-03-04 23:04:53 +00:00
#include "Graphics/CGraphics.hpp"
2016-02-15 04:00:26 +00:00
#include "boo/graphicsdev/IGraphicsDataFactory.hpp"
2018-12-08 05:30:43 +00:00
namespace urde {
2016-02-16 05:50:41 +00:00
class CVParamTransfer;
2018-12-08 05:30:43 +00:00
class CTexture {
2017-01-29 03:58:16 +00:00
public:
2018-12-08 05:30:43 +00:00
enum class EFontType {
None = -1,
OneLayer = 0, /* Fill bit0 */
OneLayerOutline = 1, /* Fill bit0, Outline bit1 */
FourLayers = 2,
TwoLayersOutlines = 3, /* Fill bit0/2, Outline bit1/3 */
TwoLayers = 4, /* Fill bit0/1 and copied to bit2/3 */
TwoLayersOutlines2 = 8 /* Fill bit2/3, Outline bit0/1 */
};
2017-01-29 03:58:16 +00:00
private:
2018-12-08 05:30:43 +00:00
ETexelFormat x0_fmt;
u16 x4_w;
u16 x6_h;
u32 x8_mips;
boo::ObjToken<boo::ITexture> m_booTex;
boo::ObjToken<boo::ITexture> m_paletteTex;
std::unique_ptr<u8[]> m_otex;
EFontType m_ftype = EFontType::None;
2019-08-04 00:02:53 +00:00
std::string m_dolphinName;
2016-02-16 05:50:41 +00:00
size_t ComputeMippedTexelCount() const;
size_t ComputeMippedBlockCountDXT1() const;
2018-12-08 05:30:43 +00:00
void BuildI4FromGCN(CInputStream& in);
void BuildI8FromGCN(CInputStream& in);
void BuildIA4FromGCN(CInputStream& in);
void BuildIA8FromGCN(CInputStream& in);
void BuildC4FromGCN(CInputStream& in);
void BuildC8FromGCN(CInputStream& in);
void BuildC14X2FromGCN(CInputStream& in);
void BuildRGB565FromGCN(CInputStream& in);
void BuildRGB5A3FromGCN(CInputStream& in);
void BuildRGBA8FromGCN(CInputStream& in);
void BuildDXT1FromGCN(CInputStream& in);
void BuildRGBA8(const void* data, size_t length);
void BuildC8(const void* data, size_t length);
void BuildC8Font(const void* data, EFontType ftype);
void BuildDXT1(const void* data, size_t length);
2019-03-03 06:19:42 +00:00
void BuildDXT3(const void* data, size_t length);
2016-02-16 05:50:41 +00:00
public:
2018-12-08 05:30:43 +00:00
CTexture(ETexelFormat, s16, s16, s32);
CTexture(std::unique_ptr<u8[]>&& in, u32 length, bool otex);
enum class EClampMode { None, One };
ETexelFormat GetTexelFormat() const { return x0_fmt; }
ETexelFormat GetMemoryCardTexelFormat() const {
return x0_fmt == ETexelFormat::C8PC ? ETexelFormat::C8 : ETexelFormat::RGB5A3;
}
u16 GetWidth() const { return x4_w; }
u16 GetHeight() const { return x6_h; }
u32 GetNumMips() const { return x8_mips; }
void Load(int slot, EClampMode clamp) const;
const boo::ObjToken<boo::ITexture>& GetBooTexture() const { return m_booTex; }
const boo::ObjToken<boo::ITexture>& GetPaletteTexture() const { return m_paletteTex; }
std::unique_ptr<u8[]> BuildMemoryCardTex(u32& sizeOut, ETexelFormat& fmtOut, std::unique_ptr<u8[]>& paletteOut) const;
const boo::ObjToken<boo::ITexture>& GetFontTexture(EFontType tp);
2019-08-04 00:02:53 +00:00
std::string_view GetDolphinName() const { return m_dolphinName; }
bool HasDolphinName() const { return !m_dolphinName.empty(); }
};
2018-12-08 05:30:43 +00:00
CFactoryFnReturn FTextureFactory(const urde::SObjectTag& tag, std::unique_ptr<u8[]>&& in, u32 len,
const urde::CVParamTransfer& vparms, CObjectReference* selfRef);
2018-12-08 05:30:43 +00:00
} // namespace urde