pctm + foundation for obj models

This commit is contained in:
2026-02-22 14:32:52 +01:00
parent 7ca48a5080
commit c051008287
16 changed files with 279 additions and 185 deletions
+41
View File
@@ -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