mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-20 10:25:40 +00:00
Initial commit of current work on Prime World Editor
This commit is contained in:
83
Resource/CTexture.h
Normal file
83
Resource/CTexture.h
Normal file
@@ -0,0 +1,83 @@
|
||||
#ifndef CTEXTURE_H
|
||||
#define CTEXTURE_H
|
||||
|
||||
#include <Common/types.h>
|
||||
#include <FileIO/FileIO.h>
|
||||
#include <gl/glew.h>
|
||||
#include "CResource.h"
|
||||
#include "ETexelFormat.h"
|
||||
|
||||
class CTexture : public CResource
|
||||
{
|
||||
friend class CTextureDecoder;
|
||||
friend class CTextureEncoder;
|
||||
|
||||
ETexelFormat mTexelFormat; // Format of decoded image data
|
||||
ETexelFormat mSourceTexelFormat; // Format of input TXTR file
|
||||
u16 mWidth, mHeight; // Image dimensions
|
||||
u32 mNumMipMaps; // The number of mipmaps this texture has
|
||||
u32 mLinearSize; // The size of the top level mipmap, in bytes
|
||||
|
||||
bool mBufferExists; // Boolean that indicates whether image data buffer has valid data
|
||||
u8 *mImgDataBuffer; // Pointer to image data buffer
|
||||
u32 mImgDataSize; // Size of image data buffer
|
||||
|
||||
bool mGLBufferExists; // Boolean that indicates whether GL buffer has valid data
|
||||
GLuint mTextureID; // ID for texture GL buffer
|
||||
|
||||
public:
|
||||
CTexture();
|
||||
CTexture(const CTexture& Source);
|
||||
CTexture(u32 Width, u32 Height);
|
||||
~CTexture();
|
||||
EResType Type();
|
||||
|
||||
bool BufferGL();
|
||||
void Bind(u32 GLTextureUnit);
|
||||
void Resize(u32 Width, u32 Height);
|
||||
bool WriteDDS(COutputStream& out);
|
||||
|
||||
// Getters
|
||||
ETexelFormat TexelFormat();
|
||||
ETexelFormat SourceTexelFormat();
|
||||
u32 Width();
|
||||
u32 Height();
|
||||
u32 NumMipMaps();
|
||||
GLuint TextureID();
|
||||
|
||||
// Static
|
||||
static u32 FormatBPP(ETexelFormat Format);
|
||||
|
||||
// Private
|
||||
private:
|
||||
void CalcLinearSize();
|
||||
u32 CalcTotalSize();
|
||||
void CopyGLBuffer();
|
||||
void DeleteBuffers();
|
||||
};
|
||||
|
||||
inline ETexelFormat CTexture::TexelFormat() {
|
||||
return mTexelFormat;
|
||||
}
|
||||
|
||||
inline ETexelFormat CTexture::SourceTexelFormat() {
|
||||
return mSourceTexelFormat;
|
||||
}
|
||||
|
||||
inline u32 CTexture::Width() {
|
||||
return (u32) mWidth;
|
||||
}
|
||||
|
||||
inline u32 CTexture::Height() {
|
||||
return (u32) mHeight;
|
||||
}
|
||||
|
||||
inline u32 CTexture::NumMipMaps() {
|
||||
return mNumMipMaps;
|
||||
}
|
||||
|
||||
inline GLuint CTexture::TextureID() {
|
||||
return mTextureID;
|
||||
}
|
||||
|
||||
#endif // CTEXTURE_H
|
||||
Reference in New Issue
Block a user