texture_group.h Source File - ClanLib SDK
Description: texture_group.h Source File

texture_group.h
1/*
2** ClanLib SDK
3** Copyright (c) 1997-2020 The ClanLib Team
4**
5** This software is provided 'as-is', without any express or implied
6** warranty. In no event will the authors be held liable for any damages
7** arising from the use of this software.
8**
9** Permission is granted to anyone to use this software for any purpose,
10** including commercial applications, and to alter it and redistribute it
11** freely, subject to the following restrictions:
12**
13** 1. The origin of this software must not be misrepresented; you must not
14** claim that you wrote the original software. If you use this software
15** in a product, an acknowledgment in the product documentation would be
16** appreciated but is not required.
17** 2. Altered source versions must be plainly marked as such, and must not be
18** misrepresented as being the original software.
19** 3. This notice may not be removed or altered from any source distribution.
20**
21** Note: Some of the libraries ClanLib may link to may have additional
22** requirements or restrictions.
23**
24** File Author(s):
25**
26** Kenneth Gangstoe
27** Magnus Norddahl
28*/
29
30#pragma once
31
32#include <memory>
33
34namespace clan
35{
38
39 class Size;
40 class Rect;
41 class Texture2D;
42 class Subtexture;
43 class TextureGroup_Impl;
44 class GraphicContext;
45
47 class TextureGroup
48 {
49 public:
51 enum TextureAllocationPolicy
52 {
53 create_new_texture,
54 search_previous_textures
55 };
56
58 TextureGroup();
59
61 TextureGroup(const Size &texture_sizes);
62
63 ~TextureGroup();
64
66 bool is_null() const { return !impl; }
67 explicit operator bool() const { return bool(impl); }
68
70 void throw_if_null() const;
71
73 int get_subtexture_count() const;
74
76 int get_subtexture_count(unsigned int texture_index) const;
77
79 int get_texture_count() const;
80
82 TextureAllocationPolicy get_texture_allocation_policy() const;
83
85 Size get_texture_sizes() const;
86
88 std::vector<Texture2D> get_textures() const;
89
91 Subtexture add(GraphicContext &context, const Size &size);
92
98 void remove(Subtexture &subtexture);
99
101 void set_texture_allocation_policy(TextureAllocationPolicy policy);
102
107 void insert_texture(Texture2D &texture, const Rect &texture_rect);
108
109 private:
110 std::shared_ptr<TextureGroup_Impl> impl;
111 };
112
114}
clan::GraphicContext
Interface to drawing graphics.
Definition graphic_context.h:257
clan::Rect
2D (left,top,right,bottom) rectangle structure - Integer
Definition rect.h:489
clan::Size
2D (width,height) size structure - Integer
Definition size.h:171
clan::Subtexture
Sub-texture description.
Definition subtexture.h:45
clan::Texture2D
2D texture object class.
Definition texture_2d.h:41
clan::TextureGroup
Texture grouping class.
Definition texture_group.h:48
clan::TextureGroup::remove
void remove(Subtexture &subtexture)
Deallocate space, from a previously allocated texture.
clan::TextureGroup::get_textures
std::vector< Texture2D > get_textures() const
Returns the textures.
clan::TextureGroup::TextureGroup
TextureGroup(const Size &texture_sizes)
Constructs a texture group.
clan::TextureGroup::get_subtexture_count
int get_subtexture_count() const
Returns the amount of sub-textures allocated in group.
clan::TextureGroup::get_texture_sizes
Size get_texture_sizes() const
Returns the size of the textures used by this texture group.
clan::TextureGroup::~TextureGroup
~TextureGroup()
clan::TextureGroup::TextureGroup
TextureGroup()
Constructs a null instance.
clan::TextureGroup::insert_texture
void insert_texture(Texture2D &texture, const Rect &texture_rect)
Insert an existing texture into the texture group.
clan::TextureGroup::get_texture_allocation_policy
TextureAllocationPolicy get_texture_allocation_policy() const
Returns the texture allocation policy.
clan::TextureGroup::get_texture_count
int get_texture_count() const
Returns the amount of textures used by group.
clan::TextureGroup::set_texture_allocation_policy
void set_texture_allocation_policy(TextureAllocationPolicy policy)
Set the texture allocation policy.
clan::TextureGroup::TextureAllocationPolicy
TextureAllocationPolicy
Texture allocation policy.
Definition texture_group.h:52
clan::TextureGroup::create_new_texture
@ create_new_texture
Definition texture_group.h:53
clan::TextureGroup::search_previous_textures
@ search_previous_textures
Definition texture_group.h:54
clan::TextureGroup::is_null
bool is_null() const
Returns true if this object is invalid.
Definition texture_group.h:66
clan::TextureGroup::throw_if_null
void throw_if_null() const
Throw an exception if this object is invalid.
clan::TextureGroup::add
Subtexture add(GraphicContext &context, const Size &size)
Allocate space for another sub texture.
clan::TextureGroup::get_subtexture_count
int get_subtexture_count(unsigned int texture_index) const
Returns the amount of sub-textures for a specific texture index.
clan
Definition clanapp.h:36