texture_group.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2015 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 
31 #pragma once
32 
33 #include <memory>
34 
35 namespace clan
36 {
39 
40 class Size;
41 class Rect;
42 class Texture2D;
43 class Subtexture;
44 class TextureGroup_Impl;
45 class GraphicContext;
46 
49 {
52 public:
55  {
58  };
59 
63 public:
66 
68  TextureGroup(const Size &texture_sizes);
69 
71 
75 public:
76 
78  bool is_null() const { return !impl; }
79 
81  void throw_if_null() const;
82 
84  int get_subtexture_count() const;
85 
87  int get_subtexture_count(unsigned int texture_index) const;
88 
90  int get_texture_count() const;
91 
94 
97 
99  std::vector<Texture2D> get_textures() const;
100 
104 public:
106  Subtexture add(GraphicContext &context, const Size &size);
107 
113  void remove(Subtexture &subtexture);
114 
117 
122  void insert_texture(Texture2D &texture, const Rect &texture_rect);
123 
127 private:
128  std::shared_ptr<TextureGroup_Impl> impl;
130 };
131 
132 }
133 
int get_subtexture_count(unsigned int texture_index) const
Returns the amount of sub-textures for a specific texture index.
TextureAllocationPolicy
Texture allocation policy.
Definition: texture_group.h:55
Subtexture add(GraphicContext &context, const Size &size)
Allocate space for another sub texture.
TextureAllocationPolicy get_texture_allocation_policy() const
Returns the texture allocation policy.
2D (left,top,right,bottom) rectangle structure - Integer
Definition: rect.h:471
void insert_texture(Texture2D &texture, const Rect &texture_rect)
Insert an existing texture into the texture group.
bool is_null() const
Returns true if this object is invalid.
Definition: texture_group.h:78
int get_texture_count() const
Returns the amount of textures used by group.
2D texture object class.
Definition: texture_2d.h:42
@ create_new_texture
Definition: texture_group.h:56
TextureGroup(const Size &texture_sizes)
Constructs a texture group.
Interface to drawing graphics.
Definition: graphic_context.h:258
@ search_previous_textures
Definition: texture_group.h:57
Texture grouping class.
Definition: texture_group.h:49
std::vector< Texture2D > get_textures() const
Returns the textures.
Size get_texture_sizes() const
Returns the size of the textures used by this texture group.
Definition: clanapp.h:36
void set_texture_allocation_policy(TextureAllocationPolicy policy)
Set the texture allocation policy.
Sub-texture description.
Definition: subtexture.h:46
2D (width,height) size structure - Integer
Definition: size.h:157
int get_subtexture_count() const
Returns the amount of sub-textures allocated in group.
TextureGroup()
Constructs a null instance.
void remove(Subtexture &subtexture)
Deallocate space, from a previously allocated texture.
void throw_if_null() const
Throw an exception if this object is invalid.