39 lines
854 B
C++
39 lines
854 B
C++
#pragma once
|
|
|
|
#include "raylib.h"
|
|
#include <string>
|
|
#include <unordered_map>
|
|
|
|
struct TextureSource {
|
|
std::string path;
|
|
};
|
|
|
|
class TextureManager
|
|
{
|
|
public:
|
|
TextureManager();
|
|
~TextureManager();
|
|
|
|
// Load a texture from a file
|
|
// Returns a unique ID for the texture, or 0 on failure
|
|
unsigned int Load(const std::string& path);
|
|
|
|
// Unload a texture by ID
|
|
void Unload(unsigned int id);
|
|
|
|
// Get a texture by ID (returns nullptr if not found)
|
|
Texture2D* Get(unsigned int id);
|
|
|
|
// Get source metadata for a texture if available
|
|
const TextureSource* GetSource(unsigned int id) const;
|
|
|
|
// Unload all textures
|
|
void UnloadAll();
|
|
|
|
private:
|
|
std::unordered_map<unsigned int, Texture2D> textures;
|
|
std::unordered_map<unsigned int, TextureSource> textureSources;
|
|
unsigned int nextId;
|
|
bool unloaded;
|
|
};
|