2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2016-02-06 00:34:40 +00:00
|
|
|
|
2019-09-28 02:53:03 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "Runtime/CFactoryMgr.hpp"
|
|
|
|
#include "Runtime/GCNTypes.hpp"
|
2022-02-27 02:18:58 +00:00
|
|
|
#include "Runtime/Graphics/CGraphics.hpp"
|
2019-09-28 02:53:03 +00:00
|
|
|
#include "Runtime/IObj.hpp"
|
2022-02-19 13:04:45 +00:00
|
|
|
#include "Runtime/Streams/IOStreams.hpp"
|
2022-02-27 02:18:58 +00:00
|
|
|
#include "Runtime/Graphics/CGraphicsPalette.hpp"
|
2019-09-28 02:53:03 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2016-02-16 05:50:41 +00:00
|
|
|
class CVParamTransfer;
|
2019-12-11 04:51:33 +00:00
|
|
|
class CTextureInfo;
|
2016-02-06 00:34:40 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CTexture {
|
2022-02-27 02:18:58 +00:00
|
|
|
class CDumpedBitmapDataReloader {
|
|
|
|
int x0_;
|
|
|
|
u32 x4_;
|
|
|
|
int x8_;
|
|
|
|
u32 xc_;
|
|
|
|
bool x10_;
|
|
|
|
int x14_;
|
|
|
|
void* x18_;
|
|
|
|
};
|
|
|
|
|
2017-01-29 03:58:16 +00:00
|
|
|
public:
|
2022-02-27 02:18:58 +00:00
|
|
|
enum class EClampMode {
|
|
|
|
Clamp,
|
|
|
|
Repeat,
|
|
|
|
Mirror,
|
|
|
|
};
|
|
|
|
|
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;
|
2022-02-27 02:18:58 +00:00
|
|
|
u8 x8_mips;
|
|
|
|
u8 x9_bitsPerPixel;
|
|
|
|
u32 xc_memoryAllocated;
|
|
|
|
std::unique_ptr<CGraphicsPalette> x10_graphicsPalette;
|
|
|
|
std::unique_ptr<CDumpedBitmapDataReloader> x14_bitmapReloader;
|
|
|
|
u32 x18_gxFormat;
|
|
|
|
u32 x1c_gxCIFormat;
|
|
|
|
/* GXTexObj x20_texObj */
|
|
|
|
EClampMode x40_clampMode;
|
|
|
|
|
2022-02-18 00:38:31 +00:00
|
|
|
aurora::gfx::TextureHandle m_tex;
|
|
|
|
aurora::gfx::TextureHandle m_paletteTex;
|
2018-12-08 05:30:43 +00:00
|
|
|
std::unique_ptr<u8[]> m_otex;
|
|
|
|
EFontType m_ftype = EFontType::None;
|
2019-12-11 04:51:33 +00:00
|
|
|
const CTextureInfo* m_textureInfo;
|
2016-02-16 05:50:41 +00:00
|
|
|
|
2019-08-14 10:04:11 +00:00
|
|
|
size_t ComputeMippedTexelCount() const;
|
|
|
|
size_t ComputeMippedBlockCountDXT1() const;
|
2022-02-18 00:38:31 +00:00
|
|
|
void BuildI4FromGCN(CInputStream& in, aurora::zstring_view label);
|
|
|
|
void BuildI8FromGCN(CInputStream& in, aurora::zstring_view label);
|
|
|
|
void BuildIA4FromGCN(CInputStream& in, aurora::zstring_view label);
|
|
|
|
void BuildIA8FromGCN(CInputStream& in, aurora::zstring_view label);
|
|
|
|
void BuildC4FromGCN(CInputStream& in, aurora::zstring_view label);
|
|
|
|
void BuildC8FromGCN(CInputStream& in, aurora::zstring_view label);
|
|
|
|
void BuildC14X2FromGCN(CInputStream& in, aurora::zstring_view label);
|
|
|
|
void BuildRGB565FromGCN(CInputStream& in, aurora::zstring_view label);
|
|
|
|
void BuildRGB5A3FromGCN(CInputStream& in, aurora::zstring_view label);
|
|
|
|
void BuildRGBA8FromGCN(CInputStream& in, aurora::zstring_view label);
|
|
|
|
void BuildDXT1FromGCN(CInputStream& in, aurora::zstring_view label);
|
|
|
|
void BuildRGBA8(const void* data, size_t length, aurora::zstring_view label);
|
|
|
|
void BuildC8(const void* data, size_t length, aurora::zstring_view label);
|
|
|
|
void BuildC8Font(const void* data, EFontType ftype, aurora::zstring_view label);
|
|
|
|
void BuildDXT1(const void* data, size_t length, aurora::zstring_view label);
|
|
|
|
void BuildDXT3(const void* data, size_t length, aurora::zstring_view label);
|
2016-02-16 05:50:41 +00:00
|
|
|
|
2022-02-27 02:18:58 +00:00
|
|
|
void InitBitmapBuffers(ETexelFormat fmt, s16 width, s16 height, s32 mips);
|
|
|
|
|
2016-02-06 00:34:40 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CTexture(ETexelFormat, s16, s16, s32);
|
2022-02-01 00:06:54 +00:00
|
|
|
CTexture(std::unique_ptr<u8[]>&& in, u32 length, bool otex, const CTextureInfo* inf, CAssetId id);
|
2018-12-08 05:30:43 +00:00
|
|
|
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; }
|
2022-02-27 02:18:58 +00:00
|
|
|
u8 GetBitsPerPixel() const { return x9_bitsPerPixel; }
|
2018-12-08 05:30:43 +00:00
|
|
|
void Load(int slot, EClampMode clamp) const;
|
2022-02-18 00:38:31 +00:00
|
|
|
const aurora::gfx::TextureHandle& GetTexture() const { return m_tex; }
|
2022-02-27 02:18:58 +00:00
|
|
|
// const boo::ObjToken<boo::ITexture>& GetBooTexture() const { return m_booTex; }
|
2022-02-18 00:38:31 +00:00
|
|
|
const aurora::gfx::TextureHandle& GetPaletteTexture() const { return m_paletteTex; }
|
2018-12-08 05:30:43 +00:00
|
|
|
std::unique_ptr<u8[]> BuildMemoryCardTex(u32& sizeOut, ETexelFormat& fmtOut, std::unique_ptr<u8[]>& paletteOut) const;
|
2022-02-18 00:38:31 +00:00
|
|
|
const aurora::gfx::TextureHandle& GetFontTexture(EFontType tp);
|
2019-08-04 00:02:53 +00:00
|
|
|
|
2019-12-11 04:51:33 +00:00
|
|
|
const CTextureInfo* GetTextureInfo() const { return m_textureInfo; }
|
2022-02-27 02:18:58 +00:00
|
|
|
|
|
|
|
static u32 TexelFormatBitsPerPixel(ETexelFormat fmt);
|
2016-02-06 00:34:40 +00:00
|
|
|
};
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
CFactoryFnReturn FTextureFactory(const metaforce::SObjectTag& tag, std::unique_ptr<u8[]>&& in, u32 len,
|
|
|
|
const metaforce::CVParamTransfer& vparms, CObjectReference* selfRef);
|
2016-02-06 00:34:40 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|