Files
ImXui/include/ImXui/TextureManager.h
T
2026-08-27 17:15:05 -07:00

36 lines
850 B
C++

#pragma once
#include <string>
#include <unordered_map>
#include <cstdint>
struct ID3D11Device;
struct ID3D11ShaderResourceView;
namespace ImXui {
class TextureManager {
public:
TextureManager() : m_device(nullptr) {}
~TextureManager() { shutdown(); }
bool init(ID3D11Device* device);
void shutdown();
void setBasePath(const std::string& path) { m_basePath = path; }
const std::string& getBasePath() const { return m_basePath; }
ID3D11ShaderResourceView* load(const std::string& relativePath);
bool getSize(const std::string& relativePath, int& w, int& h) const;
private:
ID3D11Device* m_device;
std::string m_basePath;
std::unordered_map<std::string, ID3D11ShaderResourceView*> m_cache;
std::unordered_map<std::string, int> m_widths;
std::unordered_map<std::string, int> m_heights;
};
}