ShitEngine
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
Toggle main menu visibility
载入中...
搜索中...
未找到
TextureManager.h
浏览该文件的文档.
1
#pragma once
2
3
#include <string>
4
#include <unordered_map>
5
#include <memory>
6
#include <SDL3/SDL_render.h>
7
8
#include "
ShitEngine/Core/Core.h
"
9
10
namespace
Shit
{
14
class
TextureManager
final {
15
friend
class
ResourceManager
;
// 只能通过ResourceManager来管理
16
17
public
:
18
TextureManager
(
const
TextureManager
&) =
delete
;
19
TextureManager
&
operator=
(
const
TextureManager
&) =
delete
;
20
TextureManager
(
TextureManager
&&) =
default
;
21
TextureManager
&
operator=
(
TextureManager
&&) =
default
;
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
}
Core.h
Shit::TextureManager::TextureManager
TextureManager(TextureManager &&)=default
Shit::TextureManager::TextureManager
TextureManager(const TextureManager &)=delete
Shit::TextureManager::ResourceManager
friend class ResourceManager
定义
TextureManager.h:15
Shit::TextureManager::operator=
TextureManager & operator=(TextureManager &&)=default
Shit::TextureManager::~TextureManager
~TextureManager()=default
Shit::TextureManager::operator=
TextureManager & operator=(const TextureManager &)=delete
Shit
定义
AudioPlayer.h:9
ShitEngine
Resource
TextureManager.h
制作者
1.17.0