feat: add TextureManager class

This commit is contained in:
2026-01-15 16:41:33 +08:00
parent 291074c2b5
commit cddf8d5e0b
2 changed files with 108 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
#pragma once
#include <SDL3/SDL.h>
#include <unordered_map>
#include <string>
class TextureManager {
public:
TextureManager(SDL_Renderer* renderer);
~TextureManager();
SDL_Texture* createTextureFromRect(int x, int y, SDL_FRect& rect, SDL_Color& coler);
void cleanupAllTexture();
SDL_Texture* getTexture(int x, int y);
private:
SDL_Renderer* m_renderer = nullptr;
std::unordered_map<size_t, SDL_Texture*> m_cacheTexture;
size_t makeHash(int x, int y);
};