#pragma once #include #include #include #include #include #include "../glIncludes.h" #include "BMP.h" #define TEXTURE_FILE_PATH "../res/textures/" struct Texture { std::string fileName; unsigned int width; unsigned int height; size_t textureSize; unsigned int ID; }; /** * @class textureManager * @brief Texture manager that loads in texture files to openGL * * @warning STB Image macros need to be defined in main. See commented out * defines at top * * @author Michael John * @version 01.00 * @date 10/08/2021 * Implemented STB image * * @author Michael John * @version 01.01 * @date 13/08/2021 * Implemented bmp image loader and init function. STB removed * * @todo Work out what extension is required to use glGenerateMipMap * in loadTexture function * * @bug */ class TextureManager { public: TextureManager() = default; ~TextureManager() = default; /** @brief Reads in list of texture names from filename parameter * * Use at game startup to read in all textures * @return true if successfully opened file */ bool init(const std::string& fileName); /** @brief Loads anf binds a bmp texture to openGL * * @param fileName const std::string filename of bmp to load * @return unsigned int ID assigned by openGL * */ unsigned int loadBMPTexture(const std::string& fileName, double angle = 0); /** @brief Returns texture file information * Used to read more information about the Texture loaded in. * e.g you may want to know the texture dimensions for wrapping or * mirroring * @param ID The texture ID used to bind textures in OpenGL * @return A copy of the texture strut used to read in this texture */ static const Texture& getTexture(unsigned int ID); /** @brief Returns texture struct with image information * * @param textureName filename of the struct * @return Texture struct with texture file information */ static const Texture& getTexture(const std::string& textureName); /** @brief Get the openGL assigned ID of a texture loaded in * * @param textureName name of file read in * @return OpenGL ID assigned to the parameter filename */ static unsigned int getTextureID(const std::string& textureName); /** * Indicates an empty Texture struct if ID equals DEFAULTID */ static const unsigned int DEFAULTID = 0; private: static std::vector textureList; /// stores the list of read in texture structs static Texture defaultTexture; /// default empty texture returned on failed searches };