FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
texture_manager.hpp
1/*
2 * Copyright 2024 Guillaume Guillet
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _FGE_TEXTURE_MANAGER_HPP_INCLUDED
18#define _FGE_TEXTURE_MANAGER_HPP_INCLUDED
19
20#include "FastEngine/fge_extern.hpp"
21
22#include "FastEngine/graphic/C_surface.hpp"
23#include "FastEngine/manager/C_baseManager.hpp"
24#include "FastEngine/textureType.hpp"
25#include <vector>
26
27#define FGE_TEXTURE_BAD FGE_MANAGER_BAD
28#define FGE_TEXTURE_BAD_W 32
29#define FGE_TEXTURE_BAD_H 32
30#define FGE_TEXTURE_BAD_COLOR_1 fge::Color::Black
31#define FGE_TEXTURE_BAD_COLOR_2 fge::Color::Magenta
32
33namespace fge::texture
34{
35
36struct DataBlock : manager::BaseDataBlock<TextureType>
37{
38 inline void unload() override { this->_group.clear(); }
39
40 std::vector<DataPointer> _group;
41};
42
52class FGE_API TextureManager : public manager::BaseManager<TextureType, DataBlock>
53{
54public:
55 using BaseManager::BaseManager;
56
57 bool initialize() override;
58 [[nodiscard]] bool isInitialized() override;
59 void uninitialize() override;
60
68 bool loadFromSurface(std::string_view name, fge::Surface const& surface);
76 bool loadFromFile(std::string_view name, std::filesystem::path const& path);
84 bool loadToGroupFromSurface(std::string_view name, fge::Surface const& surface) const;
85};
86
91FGE_API extern TextureManager gManager;
92
93} // namespace fge::texture
94
95#endif // _FGE_TEXTURE_MANAGER_HPP_INCLUDED
Abstraction of SDL_Surface.
Definition graphic/C_surface.hpp:55
Base class for all managers.
Definition C_baseManager.hpp:63
Manage textures.
Definition texture_manager.hpp:53
bool loadFromSurface(std::string_view name, fge::Surface const &surface)
Load a texture from a surface.
bool loadFromFile(std::string_view name, std::filesystem::path const &path)
Load a texture from a file.
bool loadToGroupFromSurface(std::string_view name, fge::Surface const &surface) const
Load a texture from a surface and add it to a group.
bool initialize() override
Initialize the manager.
FGE_API TextureManager gManager
The global texture manager.
Definition C_baseManager.hpp:42
Definition texture_manager.hpp:37