Added RenderImage

Cleaned internal CSFML code
Synchronized with trunk

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1135 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
laurentgom 2009-06-11 15:49:36 +00:00
commit 2deb8bd021
228 changed files with 15844 additions and 7152 deletions

View file

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.

View file

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.

View file

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
@ -35,6 +35,7 @@
#include <SFML/Graphics/Glyph.hpp>
#include <SFML/Graphics/Image.hpp>
#include <SFML/Graphics/PostFX.hpp>
#include <SFML/Graphics/RenderImage.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/Shape.hpp>
#include <SFML/Graphics/Sprite.hpp>

View file

@ -296,13 +296,23 @@ private :
/// Make sure the texture in video memory is updated with the
/// array of pixels
////////////////////////////////////////////////////////////
void EnsureTextureUpdate() const;
void EnsureTextureUpdate();
////////////////////////////////////////////////////////////
/// Make sure the array of pixels is updated with the
/// texture in video memory
////////////////////////////////////////////////////////////
void EnsureArrayUpdate() const;
void EnsureArrayUpdate();
////////////////////////////////////////////////////////////
/// Notify the image that an external source has modified
/// its content.
/// For internal use only (see RenderImage class).
///
/// \param Source : RenderImage that will update the image
///
////////////////////////////////////////////////////////////
void ExternalUpdate(RenderImage& Source);
////////////////////////////////////////////////////////////
/// Reset the image attributes
@ -319,15 +329,17 @@ private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
unsigned int myWidth; ///< Image width
unsigned int myHeight; ///< Image Height
unsigned int myTextureWidth; ///< Actual texture width (can be greater than image width because of padding)
unsigned int myTextureHeight; ///< Actual texture height (can be greater than image height because of padding)
unsigned int myTexture; ///< Internal texture identifier
bool myIsSmooth; ///< Status of the smooth filter
mutable std::vector<Color> myPixels; ///< Pixels of the image
mutable bool myNeedTextureUpdate; ///< Status of synchronization between pixels in central memory and the internal texture un video memory
mutable bool myNeedArrayUpdate; ///< Status of synchronization between pixels in central memory and the internal texture un video memory
unsigned int myWidth; ///< Image width
unsigned int myHeight; ///< Image Height
unsigned int myTextureWidth; ///< Actual texture width (can be greater than image width because of padding)
unsigned int myTextureHeight; ///< Actual texture height (can be greater than image height because of padding)
unsigned int myTexture; ///< Internal texture identifier
bool myIsSmooth; ///< Status of the smooth filter
std::vector<Color> myPixels; ///< Pixels of the image
bool myNeedTextureUpdate; ///< Status of synchronization between pixels in central memory and the internal texture un video memory
bool myNeedArrayUpdate; ///< Status of synchronization between pixels in central memory and the internal texture un video memory
RenderImage* myUpdateSource; ///< If not null, the image will use it as a source to update its texture
bool myPixelsFlipped; ///< To work around the inconsistency in Y orientation
};
} // namespace sf

View file

@ -0,0 +1,150 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_RENDERIMAGE_HPP
#define SFML_RENDERIMAGE_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/System/NonCopyable.hpp>
#include <SFML/Graphics/Image.hpp>
#include <SFML/Graphics/RenderTarget.hpp>
namespace sf
{
namespace priv
{
class RenderImageImpl;
}
////////////////////////////////////////////////////////////
/// Target for 2D rendering into an image that can be reused
/// in a sprite
////////////////////////////////////////////////////////////
class SFML_API RenderImage : public RenderTarget, NonCopyable
{
public :
////////////////////////////////////////////////////////////
/// Default constructor
///
////////////////////////////////////////////////////////////
RenderImage();
////////////////////////////////////////////////////////////
/// Destructor
///
////////////////////////////////////////////////////////////
virtual ~RenderImage();
////////////////////////////////////////////////////////////
/// Create the render image from its dimensions
///
/// \param Width : Width of the render image
/// \param Height : Height of the render image
/// \param DepthBuffer : Do you want a depth buffer attached? (false by default)
///
/// \return True if creation has been successful
///
////////////////////////////////////////////////////////////
bool Create(unsigned int Width, unsigned int Height, bool DepthBuffer = false);
////////////////////////////////////////////////////////////
/// Activate of deactivate the render-image as the current target
/// for rendering
///
/// \param Active : True to activate, false to deactivate (true by default)
///
/// \return True if operation was successful, false otherwise
///
////////////////////////////////////////////////////////////
bool SetActive(bool Active = true);
////////////////////////////////////////////////////////////
/// Get the width of the rendering region of the image
///
/// \return Width in pixels
///
////////////////////////////////////////////////////////////
virtual unsigned int GetWidth() const;
////////////////////////////////////////////////////////////
/// Get the height of the rendering region of the image
///
/// \return Height in pixels
///
////////////////////////////////////////////////////////////
virtual unsigned int GetHeight() const;
////////////////////////////////////////////////////////////
/// Get the target image
///
/// \return Target image
///
////////////////////////////////////////////////////////////
const Image& GetImage() const;
////////////////////////////////////////////////////////////
/// Check whether the system supports render images or not
///
/// \return True if the RenderImage class can be used
///
////////////////////////////////////////////////////////////
static bool CanUseRenderImage();
private :
friend class Image;
////////////////////////////////////////////////////////////
/// /see RenderTarget::Activate
///
////////////////////////////////////////////////////////////
virtual bool Activate(bool Active);
////////////////////////////////////////////////////////////
/// Update the pixels of the target image.
/// This function is called automatically by the image when it
/// needs to update its pixels, and is only meant for internal use.
///
/// \param Target : Target image to update
///
/// \return True if the new pixels are flipped vertically
///
////////////////////////////////////////////////////////////
bool UpdateImage(Image& Target);
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
Image myImage; ///< Target image to draw on
priv::RenderImageImpl* myRenderImage; ///< Platform / hardware specific implementation
};
} // namespace sf
#endif // SFML_RENDERIMAGE_HPP

View file

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.

View file

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.

View file

@ -1,7 +1,7 @@
////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.