Texture.hpp
00001 
00002 //
00003 // SFML - Simple and Fast Multimedia Library
00004 // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
00005 //
00006 // This software is provided 'as-is', without any express or implied warranty.
00007 // In no event will the authors be held liable for any damages arising from the use of this software.
00008 //
00009 // Permission is granted to anyone to use this software for any purpose,
00010 // including commercial applications, and to alter it and redistribute it freely,
00011 // subject to the following restrictions:
00012 //
00013 // 1. The origin of this software must not be misrepresented;
00014 //    you must not claim that you wrote the original software.
00015 //    If you use this software in a product, an acknowledgment
00016 //    in the product documentation would be appreciated but is not required.
00017 //
00018 // 2. Altered source versions must be plainly marked as such,
00019 //    and must not be misrepresented as being the original software.
00020 //
00021 // 3. This notice may not be removed or altered from any source distribution.
00022 //
00024 
00025 #ifndef SFML_TEXTURE_HPP
00026 #define SFML_TEXTURE_HPP
00027 
00029 // Headers
00031 #include <SFML/System/Resource.hpp>
00032 #include <SFML/Window/GlResource.hpp>
00033 #include <SFML/Graphics/Image.hpp>
00034 
00035 
00036 namespace sf
00037 {
00038 class Window;
00039 class Renderer;
00040 class RenderTexture;
00041 class InputStream;
00042 
00047 class SFML_API Texture : public Resource<Texture>, GlResource
00048 {
00049 public :
00050 
00057     Texture();
00058 
00065     Texture(const Texture& copy);
00066 
00071     ~Texture();
00072 
00084     bool Create(unsigned int width, unsigned int height);
00085 
00115     bool LoadFromFile(const std::string& filename, const IntRect& area = IntRect());
00116 
00147     bool LoadFromMemory(const void* data, std::size_t size, const IntRect& area = IntRect());
00148 
00178     bool LoadFromStream(sf::InputStream& stream, const IntRect& area = IntRect());
00179 
00202     bool LoadFromImage(const Image& image, const IntRect& area = IntRect());
00203 
00212     unsigned int GetWidth() const;
00213 
00222     unsigned int GetHeight() const;
00223 
00237     Image CopyToImage() const;
00238 
00255     void Update(const Uint8* pixels);
00256 
00277     void Update(const Uint8* pixels, unsigned int width, unsigned int height, unsigned int x, unsigned int y);
00278 
00297     void Update(const Image& image);
00298 
00314     void Update(const Image& image, unsigned int x, unsigned int y);
00315 
00334     void Update(const Window& window);
00335 
00351     void Update(const Window& window, unsigned int x, unsigned int y);
00352 
00362     void Bind() const;
00363 
00378     void SetSmooth(bool smooth);
00379 
00388     bool IsSmooth() const;
00389 
00402     FloatRect GetTexCoords(const IntRect& rectangle) const;
00403 
00412     Texture& operator =(const Texture& right);
00413 
00424     static unsigned int GetMaximumSize();
00425 
00426 private :
00427 
00428     friend class Renderer;
00429     friend class RenderTexture;
00430 
00444     static unsigned int GetValidSize(unsigned int size);
00445 
00447     // Member data
00449     unsigned int myWidth;         
00450     unsigned int myHeight;        
00451     unsigned int myTextureWidth;  
00452     unsigned int myTextureHeight; 
00453     unsigned int myTexture;       
00454     bool         myIsSmooth;      
00455     mutable bool myPixelsFlipped; 
00456 };
00457 
00458 } // namespace sf
00459 
00460 
00461 #endif // SFML_TEXTURE_HPP
00462