37 lines
1.0 KiB
C++
37 lines
1.0 KiB
C++
#pragma once
|
|
|
|
#include <SDL3/SDL.h>
|
|
|
|
#include <atomic>
|
|
#include <mutex>
|
|
#include <string>
|
|
#include <vector>
|
|
#include "../resources/ResourceManager.h"
|
|
|
|
class TextureLoader {
|
|
public:
|
|
TextureLoader(
|
|
std::atomic<int>& loadedTasks,
|
|
std::string& currentLoadingFile,
|
|
std::mutex& currentLoadingMutex,
|
|
std::vector<std::string>& assetLoadErrors,
|
|
std::mutex& assetLoadErrorsMutex);
|
|
|
|
void setResourceManager(resources::ResourceManager* mgr) { resourceManager_ = mgr; }
|
|
|
|
SDL_Texture* loadFromImage(SDL_Renderer* renderer, const std::string& path, int* outW = nullptr, int* outH = nullptr);
|
|
|
|
private:
|
|
std::atomic<int>& loadedTasks_;
|
|
std::string& currentLoadingFile_;
|
|
std::mutex& currentLoadingMutex_;
|
|
std::vector<std::string>& assetLoadErrors_;
|
|
std::mutex& assetLoadErrorsMutex_;
|
|
|
|
void setCurrentLoadingFile(const std::string& filename);
|
|
void clearCurrentLoadingFile();
|
|
void recordAssetLoadError(const std::string& message);
|
|
|
|
resources::ResourceManager* resourceManager_ = nullptr;
|
|
};
|