#ifndef _H_TEXTURE_H #define _H_TEXTURE_H #include #include #include struct SDL_Surface; class Texture { public: Texture() {} bool loadTexture(const char* imagePath); void bind(); const int getWidth() const { return textureWidth; } const int getHeight() const { return textureHeight; } ~Texture(); private: unsigned ID = 0; int textureWidth = 0; int textureHeight = 0; }; class TextureArray { private: struct TextureData { int width, height; }; public: TextureArray() : numOfLayers(0) {} /* We are going to assume each texture atlas is a square (512x512, 756x756 ... etc) */ bool loadTextures(std::vector imagePaths); void bind(); TextureData* operator[](const size_t index) { try { return textures.at(index); } catch (std::exception&) { return nullptr; } } const int getWidth() const { return canvasWidth; } const int getHeight() const { return canvasHeight; } ~TextureArray(); private: bool adjustCanvasSizes(std::vector& surfaces); size_t numOfLayers; unsigned ID = 0; std::vector textures; int canvasWidth = 0; int canvasHeight = 0; }; #endif