neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
texture_manager.hpp
Go to the documentation of this file.
1// texture_manager.hpp
2/*
3 neogfx C++ App/Game Engine
4 Copyright (c) 2015, 2020 Leigh Johnston. All Rights Reserved.
5
6 This program is free software: you can redistribute it and / or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include <neogfx/neogfx.hpp>
23#include <variant>
24#include <neolib/core/jar.hpp>
27
28namespace neogfx
29{
31 {
32 friend class texture_wrapper;
33 protected:
37 private:
39 protected:
41 public:
42 void find_texture(texture_id aId, i_ref_ptr<i_texture>& aResult) const override;
43 void clear_textures() override;
44 public:
45 void add_ref(texture_id aId) override;
46 void release(texture_id aId) override;
47 long use_count(texture_id aId) const override;
48 public:
49 std::unique_ptr<i_texture_atlas> create_texture_atlas(size const& aSize = size{ 1024.0, 1024.0 }) override;
50 private:
51 void add_sub_texture(i_sub_texture& aSubTexture) override;
52 void remove_sub_texture(i_sub_texture& aSubTexture) override;
53 protected:
54 const texture_list& textures() const;
56 texture_list::const_iterator find_texture(i_image const& aImage, rect const& aImagePart) const;
57 texture_list::iterator find_texture(i_image const& aImage, rect const& aImagePart);
59 private:
60 void cleanup();
61 private:
62 texture_list iTextures;
63 std::vector<std::unique_ptr<i_texture_atlas>> iTextureAtlases;
64 };
65}
texture_list::iterator find_texture(i_image const &aImage, rect const &aImagePart)
neolib::pair< texture_pointer, uint32_t > texture_list_entry
void find_texture(texture_id aId, i_ref_ptr< i_texture > &aResult) const override
void add_ref(texture_id aId) override
friend neolib::cookie item_cookie(texture_list_entry const &)
std::unique_ptr< i_texture_atlas > create_texture_atlas(size const &aSize=size{ 1024.0, 1024.0 }) override
void release(texture_id aId) override
void clear_textures() override
texture_list & textures()
texture_list::const_iterator find_texture(i_image const &aImage, rect const &aImagePart) const
ref_ptr< i_texture > add_texture(i_ref_ptr< i_native_texture > const &aTexture)
texture_id allocate_texture_id() override
long use_count(texture_id aId) const override
const texture_list & textures() const
neolib::jar< texture_list_entry > texture_list
ref_ptr< i_texture > texture_pointer
game::id_t texture_id
Definition i_texture.hpp:30
uint32_t cookie
Definition i_jar.hpp:44
basic_jar< T, vector< T >, cookie, MutexType > jar
Definition jar.hpp:736