#pragma once
#include <glad.h>
#include <string>
#include <unordered_map>

// Single cache for diffuse textures. Resolves names as either:
//   - builtin: "white", "black", "checker", "grid", "noise", "wood",
//              "brick", "stripes", "marble", "concrete", "dirt",
//              "rock", "grass"
//   - file path ending .bmp or .tga (uses SimpleTextureLoader)
//
// Builtins are generated procedurally in-memory at first request and cached.
class TextureCache {
public:
    static GLuint Get(const std::string& name);
    static GLuint DefaultWhite();
    static GLuint DefaultNormal();   // flat (0,0,1) encoded as (0.5,0.5,1.0)
    static void Clear();

private:
    static std::unordered_map<std::string, GLuint> cache_;
    static GLuint LoadFromFile(const std::string& path);
    static GLuint Procedural(const std::string& name);
    static GLuint UploadRGBA(const unsigned char* data, int w, int h, bool srgb);
};
