mirror of
https://github.com/zhenyan121/SporeBG-Conid.git
synced 2026-04-10 06:14:08 +08:00
feat: add TextureManager class
This commit is contained in:
27
src/graphics/texture/TextureManager.h
Normal file
27
src/graphics/texture/TextureManager.h
Normal 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);
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user