diff options
Diffstat (limited to 'source/Game/Texture.hpp')
-rw-r--r-- | source/Game/Texture.hpp | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/source/Game/Texture.hpp b/source/Game/Texture.hpp deleted file mode 100644 index 108dfa7..0000000 --- a/source/Game/Texture.hpp +++ /dev/null @@ -1,99 +0,0 @@ -#pragma once - -#include "GraphicsTags.hpp" -#include "Image.hpp" -#include "Ires.hpp" -#include "RcPtr.hpp" - -#include <glad/glad.h> -#include <cstdint> -#include <glm/glm.hpp> -#include <span> - -// TODO abstract texture traits such as component sizes from OpenGL - -struct Subregion { - float u0 = 0.0f; - float v0 = 0.0f; - float u1 = 0.0f; - float v1 = 0.0f; -}; - -struct TextureInfo { - glm::ivec2 size; - Tags::TexFilter minifyingFilter = Tags::TF_Linear; - Tags::TexFilter magnifyingFilter = Tags::TF_Linear; -}; - -class Texture : public RefCounted { - friend class TextureStitcher; - -private: - TextureInfo mInfo; - GLuint mHandle = 0; - -public: - Texture() = default; - ~Texture(); - - Texture(const Texture&) = delete; - Texture& operator=(const Texture&) = delete; - Texture(Texture&&) = default; - Texture& operator=(Texture&&) = default; - - enum ErrorCode { - EC_Success, - EC_AlreadyInitialized, - EC_FileIoFailed, - EC_InvalidImage, - }; - - ErrorCode InitFromFile(const char* filePath); - ErrorCode InitFromImage(const Image& image); - - struct AtlasSource { - std::string name; - Image image; - }; - - struct AltasElement { - std::string name; - Subregion subregion; - glm::ivec2 subregionSize; - }; - - enum PackingMode { - PM_KeepSquare, - PM_VerticalExtension, - PM_HorizontalExtension, - }; - - struct AtlasInput { - std::span<AtlasSource> sources; - PackingMode packingMode; - }; - struct AtlasOutput { - std::vector<AltasElement> elements; - }; - ErrorCode InitAtlas(const AtlasInput& in, AtlasOutput* out = nullptr); - - const TextureInfo& GetInfo() const; - GLuint GetHandle() const; - - bool IsValid() const; -}; - -class IresTexture : public IresObject { -public: - RcPtr<Texture> mInstance; - -public: - IresTexture() - : IresObject(KD_Texture) {} - - Texture* CreateInstance() const; - Texture* GetInstance(); - - void Write(IresWritingContext& ctx, rapidjson::Value& value, rapidjson::Document& root) const override; - void Read(IresLoadingContext& ctx, const rapidjson::Value& value) override; -}; |