65 lines
1.6 KiB
C++
65 lines
1.6 KiB
C++
// 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 TextureLoaderHeaderParseState {
|
|
VERSION,
|
|
WIDTH,
|
|
HEIGHT,
|
|
FORMAT,
|
|
WRAP_MODE_X,
|
|
WRAP_MODE_Y,
|
|
FILTER_MODE_MIN,
|
|
FILTER_MODE_MAG,
|
|
DONE
|
|
};
|
|
|
|
enum class TextureLoaderLoadState {
|
|
INITIAL,
|
|
ASYNC_LOADING,
|
|
};
|
|
|
|
class TextureLoader : public AssetLoader {
|
|
protected:
|
|
AssetDataLoader loader;
|
|
// int32_t width = -1, height = -1;
|
|
// uint8_t *colors;
|
|
enum TextureLoaderLoadState state;
|
|
// enum TextureFormat format;
|
|
// enum TextureWrapMode wrapModeX;
|
|
// enum TextureWrapMode wrapModeY;
|
|
// enum TextureFilterMode filterModeMin;
|
|
// enum TextureFilterMode filterModeMag;
|
|
|
|
public:
|
|
std::shared_ptr<Texture> sharedTexture;
|
|
std::weak_ptr<Texture> 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();
|
|
};
|
|
}
|