// Copyright (c) 2022 Dominic Masters // // This software is released under the MIT License. // https://opensource.org/licenses/MIT #pragma once #include "../Asset.hpp" #include "../AssetLoader.hpp" #include "display/Texture.hpp" namespace Dawn { enum TextureAssetHeaderParseState { TEXTURE_ASSET_HEADER_PARSE_STATE_VERSION, TEXTURE_ASSET_HEADER_PARSE_STATE_WIDTH, TEXTURE_ASSET_HEADER_PARSE_STATE_HEIGHT, TEXTURE_ASSET_HEADER_PARSE_STATE_FORMAT, TEXTURE_ASSET_HEADER_PARSE_STATE_WRAP_MODE_X, TEXTURE_ASSET_HEADER_PARSE_STATE_WRAP_MODE_Y, TEXTURE_ASSET_HEADER_PARSE_STATE_FILTER_MODE_MIN, TEXTURE_ASSET_HEADER_PARSE_STATE_FILTER_MODE_MAG, TEXTURE_ASSET_HEADER_PARSE_STATE_END }; class TextureAsset : public Asset { protected: AssetLoader loader; uint8_t *buffer = nullptr; int32_t width = -1, height = -1; struct Color *colors; enum TextureFormat format; enum TextureWrapMode wrapModeX; enum TextureWrapMode wrapModeY; enum TextureFilterMode filterModeMin; enum TextureFilterMode filterModeMag; public: Texture texture; /** * Constructs a texture asset loader. You should instead use the parent * asset managers' abstracted load method * * @param assetManager Asset manager this asset belongs to. * @param name File name asset to load, omitting the extension. */ TextureAsset(AssetManager *assetManager, std::string name); void updateSync() override; void updateAsync() override; /** * Dispose / Cleanup the texture asset. Will also dispose the underlying * texture itself. */ ~TextureAsset(); }; }