// Copyright (c) 2022 Dominic Masters // // This software is released under the MIT License. // https://opensource.org/licenses/MIT #pragma once #include "asset/AssetLoader.hpp" #include "asset/AssetDataLoader.hpp" #include "display/Texture.hpp" #define TEXTURE_LOADER_HEADER_SIZE 256 namespace Dawn { enum class TextureLoaderLoadState { INITIAL, ASYNC_LOADING, ASYNC_DONE, SYNC_LOADING, SYNC_DONE }; class TextureLoader : public AssetLoader { protected: AssetDataLoader loader; enum TextureLoaderLoadState state; uint8_t *data = nullptr; int32_t width = -1, height = -1; enum TextureFormat format; enum TextureWrapMode wrapX; enum TextureWrapMode wrapY; enum TextureFilterMode filterMin; enum TextureFilterMode filterMag; public: std::shared_ptr sharedTexture; std::weak_ptr weakTexture; /** * Constructs a texture asset loader. You should instead use the parent * asset managers' abstracted load method * * @param name File name asset to load, omitting the extension. */ TextureLoader(const std::string name); void updateSync() override; void updateAsync() override; /** * Dispose / Cleanup the texture asset. Will also dispose the underlying * texture itself. */ ~TextureLoader(); }; }