Bromeon
Multimedia/BigTexture.hpp
Go to the documentation of this file.
00001 
00002 //
00003 // Thor C++ Library
00004 // Copyright (c) 2011-2012 Jan Haller
00005 // 
00006 // This software is provided 'as-is', without any express or implied
00007 // warranty. In no event will the authors be held liable for any damages
00008 // arising from the use of this software.
00009 // 
00010 // Permission is granted to anyone to use this software for any purpose,
00011 // including commercial applications, and to alter it and redistribute it
00012 // freely, subject to the following restrictions:
00013 // 
00014 // 1. The origin of this software must not be misrepresented; you must not
00015 //    claim that you wrote the original software. If you use this software
00016 //    in a product, an acknowledgment in the product documentation would be
00017 //    appreciated but is not required.
00018 // 
00019 // 2. Altered source versions must be plainly marked as such, and must not be
00020 //    misrepresented as being the original software.
00021 // 
00022 // 3. This notice may not be removed or altered from any source distribution.
00023 //
00025 
00028 
00029 #ifndef THOR_BIGTEXTURE_HPP
00030 #define THOR_BIGTEXTURE_HPP
00031 
00032 #include <Thor/Detail/Swap.hpp>
00033 #include <Thor/Config.hpp>
00034 
00035 #include <SFML/Graphics/Texture.hpp>
00036 
00037 #include <vector>
00038 #include <string>
00039 
00040 
00041 namespace sf
00042 {
00043 
00044     class Sprite;
00045 
00046 } // namespace sf
00047 
00048 
00049 namespace thor
00050 {
00051 
00054     
00059 class THOR_API BigTexture
00060 {
00061     // ---------------------------------------------------------------------------------------------------------------------------
00062     // Public member functions
00063     public:
00066         void                        Swap(BigTexture& other);
00067 
00070         bool                        LoadFromImage(const sf::Image& image);
00071 
00074         bool                        LoadFromFile(const std::string& filename);
00075 
00079         bool                        LoadFromMemory(const void* data, std::size_t size);
00080 
00083         bool                        LoadFromStream(sf::InputStream& stream);
00084 
00087         unsigned int                GetWidth() const;
00088 
00091         unsigned int                GetHeight() const;
00092 
00093 
00094     // ---------------------------------------------------------------------------------------------------------------------------
00095     // Private member functions
00096     private:
00097         // Fills the sprites according to the own 2D array of textures.
00098         // The return value is the size of everything, in world coordinates.
00099         sf::Vector2f                FillSprites(const sf::Color& color, std::vector<sf::Sprite>& out) const;
00100 
00101 
00102     // ---------------------------------------------------------------------------------------------------------------------------
00103     // Private variables
00104     private:
00105         std::vector<sf::Texture>    mTextures;
00106         sf::Vector2u                mTableSize;
00107         sf::Vector2u                mPixelSize;
00108 
00109 
00110     // ---------------------------------------------------------------------------------------------------------------------------
00111     // Friends
00112     friend class BigSprite;
00113 };
00114 
00117 THOR_GLOBAL_SWAP(BigTexture)
00118 
00119 
00120 
00121 } // namespace thor
00122 
00123 #endif // THOR_BIGTEXTURE_HPP