BigTexture.hpp
Go to the documentation of this file.
1 //
3 // Thor C++ Library
4 // Copyright (c) 2011-2016 Jan Haller
5 //
6 // This software is provided 'as-is', without any express or implied
7 // warranty. In no event will the authors be held liable for any damages
8 // arising from the use of this software.
9 //
10 // Permission is granted to anyone to use this software for any purpose,
11 // including commercial applications, and to alter it and redistribute it
12 // freely, subject to the following restrictions:
13 //
14 // 1. The origin of this software must not be misrepresented; you must not
15 // claim that you wrote the original software. If you use this software
16 // in a product, an acknowledgment in the product documentation would be
17 // appreciated but is not required.
18 //
19 // 2. Altered source versions must be plainly marked as such, and must not be
20 // misrepresented as being the original software.
21 //
22 // 3. This notice may not be removed or altered from any source distribution.
23 //
25 
28 
29 #ifndef THOR_BIGTEXTURE_HPP
30 #define THOR_BIGTEXTURE_HPP
31 
32 #include <Thor/Config.hpp>
33 
34 #include <SFML/Graphics/Texture.hpp>
35 
36 #include <vector>
37 #include <string>
38 
39 
40 namespace sf
41 {
42 
43  class Sprite;
44 
45 } // namespace sf
46 
47 
48 namespace thor
49 {
50 
53 
58 class THOR_API BigTexture
59 {
60  // ---------------------------------------------------------------------------------------------------------------------------
61  // Public member functions
62  public:
65  BigTexture();
66 
69  bool loadFromImage(const sf::Image& image);
70 
73  bool loadFromFile(const std::string& filename);
74 
78  bool loadFromMemory(const void* data, std::size_t size);
79 
82  bool loadFromStream(sf::InputStream& stream);
83 
86  sf::Vector2u getSize() const;
87 
90  void setSmooth(bool smooth);
91 
94  bool isSmooth() const;
95 
96 
97  // ---------------------------------------------------------------------------------------------------------------------------
98  // Private member functions
99  private:
100  // Swaps *this with other.
101  void swap(BigTexture& other);
102 
103  // Fills the sprites according to the own 2D array of textures.
104  // The return value is the size of everything, in world coordinates.
105  sf::Vector2f fillSprites(const sf::Color& color, std::vector<sf::Sprite>& out) const;
106 
107 
108  // ---------------------------------------------------------------------------------------------------------------------------
109  // Private variables
110  private:
111  std::vector<sf::Texture> mTextures;
112  sf::Vector2u mTableSize;
113  sf::Vector2u mPixelSize;
114  bool mSmooth;
115 
116 
117  // ---------------------------------------------------------------------------------------------------------------------------
118  // Friends
119  friend class BigSprite;
120 };
121 
123 
124 } // namespace thor
125 
126 #endif // THOR_BIGTEXTURE_HPP
Definition: AnimationMap.hpp:42
Class for textures which are too big for sf::Texture.
Definition: BigTexture.hpp:58
Sprite using big textures.
Definition: BigSprite.hpp:64
Configuration header of the library.
Definition: BigSprite.hpp:41