pctm + foundation for obj models
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user