diff options
Diffstat (limited to 'Client/Source/Graphics/Texture.h')
-rw-r--r-- | Client/Source/Graphics/Texture.h | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/Client/Source/Graphics/Texture.h b/Client/Source/Graphics/Texture.h new file mode 100644 index 0000000..cf423e1 --- /dev/null +++ b/Client/Source/Graphics/Texture.h @@ -0,0 +1,94 @@ +#pragma once +#include <exception> +#include <string> + +#include "../Math/Math.h" +#include "../Utilities/UtilMacros.h" +#include "../Utilities/Assert.h" + +#include "OpenGL.h" + +class ImageData; + +enum ETextureType +{ + TEX_2D, + TEX_CUBE, +}; + +enum ETextureFormat +{ + RGBA32, + RGB24, + RGB16, + R8, + A8, +}; + +enum ETextureWrapMode +{ + Clamp, + Repeat, + Mirror, +}; + +enum ETextureFilterMode +{ + Nearest, + Linear, +}; + +// GPU侧的导入设置 +struct TextureSetting +{ + bool keepImageData; // 是否保存图片数据 + int type; // 图片类型 + int format; // 内部格式 + int wrapMode; // 包围 + int filterMode; // 滤波 +}; + +class TextureException : public std::exception +{ +public: + TextureException(const char* what) + : std::exception(what) + {} + TextureException(int glError) + { + g_sharedGLErrorMsg = std::to_string(glError); + std::exception(g_sharedGLErrorMsg.c_str()); + } +}; + +class Texture +{ +public: + Texture(TextureSetting setting, int width, int height)/*throw TextureException*/; // 空贴图 + Texture(TextureSetting setting, ImageData* imgData)/*throw TextureException*/; + ~Texture(); + + void UpdateSubImage(Rect rect, int format, int type, const void* data); + + GET(int, Width, m_Width); + GET(int, Height, m_Height); + + GET(GLuint, GpuID, m_GPUID); + +private: + void Init(TextureSetting setting, ImageData* imgData); + + //------------------------------------------------------------------------------ + + GLuint m_GPUID; + + int m_Width, m_Height; + + int m_Type; + int m_Format; + int m_FilterMode; + int m_WrapMode; + + bool m_KeepPixelData; // 是否保存图像像素数据,默认导入后不保存 + +};
\ No newline at end of file |