41 lines
1.0 KiB
C++
41 lines
1.0 KiB
C++
#ifndef DELTA_ASSETLOADER
|
|
#define DELTA_ASSETLOADER
|
|
|
|
#include <SDL3/SDL.h>
|
|
#include <vector>
|
|
#include <unordered_map>
|
|
#include <map>
|
|
#include <string>
|
|
|
|
#include "math.hpp"
|
|
|
|
struct SDL_SurfaceDeleter {
|
|
void operator()(SDL_Surface* surface) const {
|
|
if (surface) {
|
|
SDL_DestroySurface(surface);
|
|
}
|
|
}
|
|
};
|
|
|
|
class DeltaAssetLoader {
|
|
public:
|
|
~DeltaAssetLoader() {
|
|
for (auto& [id, surface] : textures) {
|
|
SDL_DestroySurface(surface);
|
|
}
|
|
}
|
|
|
|
void loadTexture(std::string id, const char *path);
|
|
void loadModel(std::string id, const char *path);
|
|
SDL_Surface* getSurface(const std::string& id);
|
|
void getModel(std::string id, const char *path);
|
|
private:
|
|
std::string base_path = "assets";
|
|
std::string img_path = "images";
|
|
std::string model_path = "models";
|
|
|
|
std::unordered_map<std::string, SDL_Surface*> textures;
|
|
std::unordered_map<std::string, DeltaModel> models;
|
|
};
|
|
|
|
#endif |