mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-01 00:02:45 +03:00
chore(gx): improve organization of BLP-related code
This commit is contained in:
parent
9f9a17e172
commit
9e46e15e0b
7
src/gx/Blp.hpp
Normal file
7
src/gx/Blp.hpp
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef GX_BLP_HPP
|
||||
#define GX_BLP_HPP
|
||||
|
||||
#include "gx/blp/Types.hpp"
|
||||
#include "gx/blp/CBLPFile.hpp"
|
||||
|
||||
#endif
|
||||
@ -1,5 +1,6 @@
|
||||
file(GLOB GX_SOURCES
|
||||
"*.cpp"
|
||||
"blp/*.cpp"
|
||||
"buffer/*.cpp"
|
||||
"font/*.cpp"
|
||||
"shader/*.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 <algorithm>
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
#include "gx/blp/CBLPFile.hpp"
|
||||
#include "gx/Texture.hpp"
|
||||
#include "gx/texture/CBLPFile.hpp"
|
||||
#include "util/SFile.hpp"
|
||||
#include <cstring>
|
||||
#include <storm/Error.hpp>
|
||||
#include <storm/Memory.hpp>
|
||||
#include <cstring>
|
||||
|
||||
TSGrowableArray<unsigned char> CBLPFile::s_blpFileLoadBuffer;
|
||||
|
||||
33
src/gx/blp/CBLPFile.hpp
Normal file
33
src/gx/blp/CBLPFile.hpp
Normal file
@ -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 <storm/Array.hpp>
|
||||
#include <cstdint>
|
||||
|
||||
class CBLPFile {
|
||||
public:
|
||||
// Static variables
|
||||
static TSGrowableArray<unsigned char> 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
|
||||
43
src/gx/blp/Types.hpp
Normal file
43
src/gx/blp/Types.hpp
Normal file
@ -0,0 +1,43 @@
|
||||
#ifndef GX_BLP_TYPES_HPP
|
||||
#define GX_BLP_TYPES_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
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
|
||||
@ -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 <cstdint>
|
||||
#include <storm/Array.hpp>
|
||||
|
||||
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<unsigned char> 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
|
||||
Loading…
Reference in New Issue
Block a user