ShitEngine
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
载入中...
搜索中...
未找到
TextureManager.h
浏览该文件的文档.
1#pragma once
2
3#include <string>
4#include <unordered_map>
5#include <memory>
6#include <SDL3/SDL_render.h>
7
9
10namespace Shit {
14 class TextureManager final {
15 friend class ResourceManager; // 只能通过ResourceManager来管理
16
17 public:
22 ~TextureManager() = default;
23
24 private:
25 TextureManager() = default;
26
27 struct SDLTextureDeleter {
28 void operator()(SDL_Texture* texture) const {
29 if (texture) {
30 SDL_DestroyTexture(texture);
31 }
32 }
33 };
34
35 SDL_Texture* loadTexture(const std::string& filePath);
36 SDL_Texture* getTexture(const std::string& filePath);
37 void unloadTexture(const std::string& filePath);
38 void clearTexture();
39
40 std::unordered_map<std::string, std::unique_ptr<SDL_Texture, SDLTextureDeleter>> m_textures;
41 };
42}
TextureManager(TextureManager &&)=default
TextureManager(const TextureManager &)=delete
friend class ResourceManager
定义 TextureManager.h:15
TextureManager & operator=(TextureManager &&)=default
~TextureManager()=default
TextureManager & operator=(const TextureManager &)=delete
定义 AudioPlayer.h:9