From 60cbbdec07ab7a5636eac5b3c024ae44e937f4d4 Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 13 Dec 2021 00:07:19 +0800 Subject: +init --- Client/Source/Graphics/Texture.h | 94 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 Client/Source/Graphics/Texture.h (limited to 'Client/Source/Graphics/Texture.h') 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 +#include + +#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 -- cgit v1.1-26-g67d0