#pragma once #include "RcPtr.hpp" #include #include #include // TODO abstract texture traits such as component sizes from OpenGL class TextureInfo { public: glm::ivec2 size; bool isAtlas = false; }; 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 Filtering { LinearFilter, NearestFilter, }; struct TextureProperties { Filtering minifyingFilter = LinearFilter; Filtering magnifyingFilter = LinearFilter; }; bool InitFromFile(const char* filePath, const TextureProperties& props, bool flipVertically = false); // bool InitFromImage(const Image& image, const TextureProperties& props, bool flipVertically = false); const TextureInfo& GetInfo() const; GLuint GetHandle() const; bool IsValid() const; }; /// A pure numerical subregion of a texture. u0/v0 are the UV coordinates of bottom left /// corner, and u1/v1 are the top left corner. struct Subregion { /// Bottom left corner float u0 = 0.0f; float v0 = 0.0f; /// Top right corner float u1 = 0.0f; float v1 = 0.0f; }; /// A subregion of a specific texture. struct TextureSubregion : public Subregion { RcPtr atlasTexture; };