diff --git a/src/gx/Blp.hpp b/src/gx/Blp.hpp new file mode 100644 index 0000000..7659dcf --- /dev/null +++ b/src/gx/Blp.hpp @@ -0,0 +1,7 @@ +#ifndef GX_BLP_HPP +#define GX_BLP_HPP + +#include "gx/blp/Types.hpp" +#include "gx/blp/CBLPFile.hpp" + +#endif diff --git a/src/gx/CMakeLists.txt b/src/gx/CMakeLists.txt index 33338b0..482d699 100644 --- a/src/gx/CMakeLists.txt +++ b/src/gx/CMakeLists.txt @@ -1,5 +1,6 @@ file(GLOB GX_SOURCES "*.cpp" + "blp/*.cpp" "buffer/*.cpp" "font/*.cpp" "shader/*.cpp" diff --git a/src/gx/Texture.cpp b/src/gx/Texture.cpp index a97c494..4d7cf73 100644 --- a/src/gx/Texture.cpp +++ b/src/gx/Texture.cpp @@ -1,7 +1,7 @@ #include "gx/Texture.hpp" +#include "gx/Blp.hpp" #include "gx/Device.hpp" #include "gx/Gx.hpp" -#include "gx/texture/CBLPFile.hpp" #include "util/Filesystem.hpp" #include "util/SFile.hpp" #include diff --git a/src/gx/texture/CBLPFile.cpp b/src/gx/blp/CBLPFile.cpp similarity index 99% rename from src/gx/texture/CBLPFile.cpp rename to src/gx/blp/CBLPFile.cpp index 106a203..93b602c 100644 --- a/src/gx/texture/CBLPFile.cpp +++ b/src/gx/blp/CBLPFile.cpp @@ -1,9 +1,9 @@ +#include "gx/blp/CBLPFile.hpp" #include "gx/Texture.hpp" -#include "gx/texture/CBLPFile.hpp" #include "util/SFile.hpp" -#include #include #include +#include TSGrowableArray CBLPFile::s_blpFileLoadBuffer; diff --git a/src/gx/blp/CBLPFile.hpp b/src/gx/blp/CBLPFile.hpp new file mode 100644 index 0000000..552ab0d --- /dev/null +++ b/src/gx/blp/CBLPFile.hpp @@ -0,0 +1,33 @@ +#ifndef GX_BLP_C_BLP_FILE_HPP +#define GX_BLP_C_BLP_FILE_HPP + +#include "gx/blp/Types.hpp" +#include "gx/Types.hpp" +#include +#include + +class CBLPFile { + public: + // Static variables + static TSGrowableArray s_blpFileLoadBuffer; + + // Member variables + MipBits* m_images = nullptr; + BLPHeader m_header; + void* m_inMemoryImage = nullptr; + int32_t m_inMemoryNeedsFree; + uint32_t m_numLevels; + uint32_t m_quality = 100; + void* m_colorMapping; + MipMapAlgorithm m_mipMapAlgorithm = MMA_BOX; + char* m_lockDecompMem; + + // Member functions + void Close(); + int32_t Lock2(const char*, PIXEL_FORMAT, uint32_t, unsigned char*, uint32_t&); + int32_t LockChain2(const char*, PIXEL_FORMAT, MipBits*&, uint32_t, int32_t); + int32_t Open(const char*, int32_t); + int32_t Source(void*); +}; + +#endif diff --git a/src/gx/blp/Types.hpp b/src/gx/blp/Types.hpp new file mode 100644 index 0000000..7927ff0 --- /dev/null +++ b/src/gx/blp/Types.hpp @@ -0,0 +1,43 @@ +#ifndef GX_BLP_TYPES_HPP +#define GX_BLP_TYPES_HPP + +#include + +enum MipMapAlgorithm { + MMA_BOX = 0x0, + MMA_CUBIC = 0x1, + MMA_FULLDFT = 0x2, + MMA_KAISER = 0x3, + MMA_LINEARLIGHTKAISER = 0x4, +}; + +struct BlpPalPixel { + char b; + char g; + char r; + char pad; +}; + +struct BLPHeader { + uint32_t magic; + uint32_t formatVersion; + char colorEncoding; + char alphaSize; + char preferredFormat; + char hasMips; + uint32_t width; + uint32_t height; + uint32_t mipOffsets[16]; + uint32_t mipSizes[16]; + + union { + BlpPalPixel palette[256]; + + struct { + uint32_t headerSize; + char headerData[1020]; + } jpeg; + } extended; +}; + +#endif diff --git a/src/gx/texture/CBLPFile.hpp b/src/gx/texture/CBLPFile.hpp deleted file mode 100644 index 4ad468b..0000000 --- a/src/gx/texture/CBLPFile.hpp +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef GX_TEXTURE_C_BLP_FILE_HPP -#define GX_TEXTURE_C_BLP_FILE_HPP - -#include "gx/Types.hpp" -#include "gx/texture/CGxTex.hpp" -#include -#include - -enum MipMapAlgorithm { - MMA_BOX = 0x0, - MMA_CUBIC = 0x1, - MMA_FULLDFT = 0x2, - MMA_KAISER = 0x3, - MMA_LINEARLIGHTKAISER = 0x4, -}; - -struct BlpPalPixel { - char b; - char g; - char r; - char pad; -}; - -class CBLPFile { - struct BLPHeader { - uint32_t magic; - uint32_t formatVersion; - char colorEncoding; - char alphaSize; - char preferredFormat; - char hasMips; - uint32_t width; - uint32_t height; - uint32_t mipOffsets[16]; - uint32_t mipSizes[16]; - - union { - BlpPalPixel palette[256]; - - struct { - uint32_t headerSize; - char headerData[1020]; - } jpeg; - } extended; - }; - - public: - // Static variables - static TSGrowableArray s_blpFileLoadBuffer; - - // Member variables - MipBits* m_images = nullptr; - BLPHeader m_header; - void* m_inMemoryImage = nullptr; - int32_t m_inMemoryNeedsFree; - uint32_t m_numLevels; - uint32_t m_quality = 100; - void* m_colorMapping; - MipMapAlgorithm m_mipMapAlgorithm = MMA_BOX; - char* m_lockDecompMem; - - // Member functions - void Close(void); - int32_t Lock2(const char*, PIXEL_FORMAT, uint32_t, unsigned char*, uint32_t&); - int32_t LockChain2(const char*, PIXEL_FORMAT, MipBits*&, uint32_t, int32_t); - int32_t Open(const char*, int32_t); - int32_t Source(void*); -}; - -#endif