neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
i_texture_manager.hpp
Go to the documentation of this file.
1// i_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 <neolib/core/jar.hpp>
28
29namespace neogfx
30{
31 class i_native_texture;
32
34 {
35 friend class texture_atlas;
36 public:
37 struct texture_not_found : std::logic_error { texture_not_found() : std::logic_error("neogfx::i_texture_manager::texture_not_found") {} };
38 private:
39 virtual texture_id allocate_texture_id() = 0;
40 public:
42 {
43 ref_ptr<i_texture> result;
44 find_texture(aId, result);
45 return result;
46 }
47 virtual void find_texture(texture_id aId, i_ref_ptr<i_texture>& aResult) const = 0;
49 {
50 ref_ptr<i_texture> result;
51 create_texture(aExtents, aDpiScaleFactor, aSampling, aDataFormat, aDataType, aColorSpace, aColor, result);
52 return result;
53 }
54 virtual void create_texture(neogfx::size const& aExtents, dimension aDpiScaleFactor, texture_sampling aSampling, texture_data_format aDataFormat, texture_data_type aDataType, color_space aColorSpace, optional_color const& aColor, i_ref_ptr<i_texture>& aResult) = 0;
56 {
57 return create_texture(aImage, rect{ point{}, aImage.extents() }, aDataFormat, aDataType);
58 }
60 {
61 ref_ptr<i_texture> result;
62 create_texture(aImage, aImagePart, aDataFormat, aDataType, result);
63 return result;
64 }
65 virtual void create_texture(i_image const& aImage, const rect& aImagePart, texture_data_format aDataFormat, texture_data_type aDataType, i_ref_ptr<i_texture>& aResult) = 0;
66 virtual void clear_textures() = 0;
67 public:
68 virtual std::unique_ptr<i_texture_atlas> create_texture_atlas(const size& aSize = size{ 1024.0, 1024.0 }) = 0;
69 private:
70 virtual void add_sub_texture(i_sub_texture& aSubTexture) = 0;
71 virtual void remove_sub_texture(i_sub_texture& aSubTexture) = 0;
72 public:
73 static uuid const& iid() { static uuid const sIid{ 0xbc995572, 0x980e, 0x40cd, 0xa13e,{ 0x83, 0x66, 0xc1, 0x73, 0x50, 0xf4 } }; return sIid; }
74 };
75}
virtual const neogfx::size & extents() const =0
ref_ptr< i_texture > find_texture(texture_id aId) const
ref_ptr< i_texture > create_texture(i_image const &aImage, const rect &aImagePart, texture_data_format aDataFormat=texture_data_format::RGBA, texture_data_type aDataType=texture_data_type::UnsignedByte)
virtual void create_texture(neogfx::size const &aExtents, dimension aDpiScaleFactor, texture_sampling aSampling, texture_data_format aDataFormat, texture_data_type aDataType, color_space aColorSpace, optional_color const &aColor, i_ref_ptr< i_texture > &aResult)=0
ref_ptr< i_texture > create_texture(neogfx::size const &aExtents, dimension aDpiScaleFactor=1.0, texture_sampling aSampling=texture_sampling::NormalMipmap, texture_data_format aDataFormat=texture_data_format::RGBA, texture_data_type aDataType=texture_data_type::UnsignedByte, color_space aColorSpace=color_space::sRGB, optional_color const &aColor=optional_color())
virtual void find_texture(texture_id aId, i_ref_ptr< i_texture > &aResult) const =0
ref_ptr< i_texture > create_texture(i_image const &aImage, texture_data_format aDataFormat=texture_data_format::RGBA, texture_data_type aDataType=texture_data_type::UnsignedByte)
virtual void clear_textures()=0
virtual std::unique_ptr< i_texture_atlas > create_texture_atlas(const size &aSize=size{ 1024.0, 1024.0 })=0
virtual void create_texture(i_image const &aImage, const rect &aImagePart, texture_data_format aDataFormat, texture_data_type aDataType, i_ref_ptr< i_texture > &aResult)=0
static uuid const & iid()
optional< color > optional_color
Definition color.hpp:1069
default_geometry_value_type dimension
game::id_t texture_id
Definition i_texture.hpp:30
texture_data_type
Definition i_texture.hpp:64
texture_data_format
Definition i_texture.hpp:56
texture_sampling
Definition i_texture.hpp:42