#pragma once #include "DeerRender/Render/Texture.h" #include "DeerRender/Resource.h" #include "DeerRender/Tools/Memory.h" namespace Deer { enum TextureFormat : uint32_t { NONE = 0, R8 = 1, RGB8 = 3, RGBA8 = 4 }; struct TextureData { TextureData() = default; TextureData(TextureFormat _format, uint32_t _width, uint32_t _height) : height(_height), width(_width), textureFormat(_format) { textureData = MakeScope(getSize()); } inline uint8_t* getPixel(uint32_t x, uint32_t y) { return &textureData[(y * width + x) * (int)textureFormat]; } inline TextureFormat getTextureFormat() const { return textureFormat; } inline uint32_t getWidth() const { return width; } inline uint32_t getHeight() const { return height; } inline const uint8_t* getData() const { return textureData.get(); } inline uint8_t* getData() { return textureData.get(); } inline int getSize() { return width * height * (int)textureFormat; } private: Scope textureData; TextureFormat textureFormat = NONE; uint32_t width = 0; uint32_t height = 0; }; template <> class ResourceBuilder { public: using BaseDataType = TextureData; static Scope buildResource(const BaseDataType& baseData); }; } // namespace Deer