Audio.hpp   Audio.hpp 
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// //
// SFML - Simple and Fast Multimedia Library // SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// //
// This software is provided 'as-is', without any express or implied warran ty. // This software is provided 'as-is', without any express or implied warran ty.
// In no event will the authors be held liable for any damages arising from the use of this software. // 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, // Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it f reely, // including commercial applications, and to alter it and redistribute it f reely,
// subject to the following restrictions: // subject to the following restrictions:
// //
// 1. The origin of this software must not be misrepresented; // 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software. // you must not claim that you wrote the original software.
skipping to change at line 42 skipping to change at line 42
#include <SFML/System.hpp> #include <SFML/System.hpp>
#include <SFML/Audio/Listener.hpp> #include <SFML/Audio/Listener.hpp>
#include <SFML/Audio/Music.hpp> #include <SFML/Audio/Music.hpp>
#include <SFML/Audio/Sound.hpp> #include <SFML/Audio/Sound.hpp>
#include <SFML/Audio/SoundBuffer.hpp> #include <SFML/Audio/SoundBuffer.hpp>
#include <SFML/Audio/SoundBufferRecorder.hpp> #include <SFML/Audio/SoundBufferRecorder.hpp>
#include <SFML/Audio/SoundRecorder.hpp> #include <SFML/Audio/SoundRecorder.hpp>
#include <SFML/Audio/SoundStream.hpp> #include <SFML/Audio/SoundStream.hpp>
#endif // SFML_AUDIO_HPP #endif // SFML_AUDIO_HPP
////////////////////////////////////////////////////////////
/// \defgroup audio Audio module
///
/// Sounds, streaming (musics or custom sources), recording,
/// spatialization.
///
////////////////////////////////////////////////////////////
 End of changes. 2 change blocks. 
1 lines changed or deleted 1 lines changed or added


 Clock.hpp   Clock.hpp 
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// //
// SFML - Simple and Fast Multimedia Library // SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// //
// This software is provided 'as-is', without any express or implied warran ty. // This software is provided 'as-is', without any express or implied warran ty.
// In no event will the authors be held liable for any damages arising from the use of this software. // 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, // Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it f reely, // including commercial applications, and to alter it and redistribute it f reely,
// subject to the following restrictions: // subject to the following restrictions:
// //
// 1. The origin of this software must not be misrepresented; // 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software. // you must not claim that you wrote the original software.
skipping to change at line 31 skipping to change at line 31
// 3. This notice may not be removed or altered from any source distributio n. // 3. This notice may not be removed or altered from any source distributio n.
// //
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#ifndef SFML_CLOCK_HPP #ifndef SFML_CLOCK_HPP
#define SFML_CLOCK_HPP #define SFML_CLOCK_HPP
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Config.hpp> #include <SFML/System/Export.hpp>
#include <SFML/System/Time.hpp>
namespace sf namespace sf
{ {
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Clock is an utility class for manipulating time /// \brief Utility class that measures the elapsed time
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class SFML_API Clock class SFML_SYSTEM_API Clock
{ {
public : public :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Default constructor /// \brief Default constructor
///
/// The clock starts automatically after being constructed.
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Clock(); Clock();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the time elapsed since last reset /// \brief Get the elapsed time
///
/// This function returns the time elapsed since the last call
/// to restart() (or the construction of the instance if restart()
/// has not been called).
/// ///
/// \return Time elapsed, in seconds /// \return Time elapsed
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
float GetElapsedTime() const; Time getElapsedTime() const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Restart the timer /// \brief Restart the clock
///
/// This function puts the time counter back to zero.
/// It also returns the time elapsed since the clock was started.
///
/// \return Time elapsed
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Reset(); Time restart();
private : private :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
double myStartTime; ///< Time of last reset Time m_startTime; ///< Time of last reset, in microseconds
}; };
} // namespace sf } // namespace sf
#endif // SFML_CLOCK_HPP #endif // SFML_CLOCK_HPP
////////////////////////////////////////////////////////////
/// \class sf::Clock
/// \ingroup system
///
/// sf::Clock is a lightweight class for measuring time.
///
/// Its provides the most precise time that the underlying
/// OS can achieve (generally microseconds or nanoseconds).
/// It also ensures monotonicity, which means that the returned
/// time can never go backward, even if the system time is
/// changed.
///
/// Usage example:
/// \code
/// sf::Clock clock;
/// ...
/// Time time1 = clock.getElapsedTime();
/// ...
/// Time time2 = clock.restart();
/// \endcode
///
/// The sf::Time value returned by the clock can then be
/// converted to a number of seconds, milliseconds or even
/// microseconds.
///
/// \see sf::Time
///
////////////////////////////////////////////////////////////
 End of changes. 12 change blocks. 
11 lines changed or deleted 24 lines changed or added


 Color.hpp   Color.hpp 
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// //
// SFML - Simple and Fast Multimedia Library // SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// //
// This software is provided 'as-is', without any express or implied warran ty. // This software is provided 'as-is', without any express or implied warran ty.
// In no event will the authors be held liable for any damages arising from the use of this software. // 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, // Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it f reely, // including commercial applications, and to alter it and redistribute it f reely,
// subject to the following restrictions: // subject to the following restrictions:
// //
// 1. The origin of this software must not be misrepresented; // 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software. // you must not claim that you wrote the original software.
skipping to change at line 31 skipping to change at line 31
// 3. This notice may not be removed or altered from any source distributio n. // 3. This notice may not be removed or altered from any source distributio n.
// //
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#ifndef SFML_COLOR_HPP #ifndef SFML_COLOR_HPP
#define SFML_COLOR_HPP #define SFML_COLOR_HPP
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Config.hpp> #include <SFML/Graphics/Export.hpp>
namespace sf namespace sf
{ {
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Color is an utility class for manipulating /// \brief Utility class for manpulating RGBA colors
/// 32-bits RGBA colors ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class SFML_API Color class SFML_GRAPHICS_API Color
{ {
public : public :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Default constructor /// \brief Default constructor
///
////////////////////////////////////////////////////////////
Color();
////////////////////////////////////////////////////////////
/// Construct the color from its 4 RGBA components
///
/// \param R : Red component (0 .. 255)
/// \param G : Green component (0 .. 255)
/// \param B : Blue component (0 .. 255)
/// \param A : Alpha component (0 .. 255) (255 by default)
///
////////////////////////////////////////////////////////////
Color(Uint8 R, Uint8 G, Uint8 B, Uint8 A = 255);
////////////////////////////////////////////////////////////
/// Operator += overload to add a color
///
/// \param Other : Color to add
/// ///
/// \return Component-wise saturated addition of the two colors /// Constructs an opaque black color. It is equivalent to
/// sf::Color(0, 0, 0, 255).
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Color& operator +=(const Color& Other); Color();
////////////////////////////////////////////////////////////
/// Operator *= overload to modulate a color
///
/// \param Other : Color to modulate
///
/// \return Component-wise multiplication of the two colors
///
////////////////////////////////////////////////////////////
Color& operator *=(const Color& Other);
////////////////////////////////////////////////////////////
/// Compare two colors (for equality)
///
/// \param Other : Color to compare
///
/// \return True if colors are equal
///
////////////////////////////////////////////////////////////
bool operator ==(const Color& Other) const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Compare two colors (for difference) /// \brief Construct the color from its 4 RGBA components
///
/// \param Other : Color to compare
/// ///
/// \return True if colors are different /// \param red Red component (in the range [0, 255])
/// \param green Green component (in the range [0, 255])
/// \param blue Blue component (in the range [0, 255])
/// \param alpha Alpha (opacity) component (in the range [0, 255])
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
bool operator !=(const Color& Other) const; Color(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha = 255);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Static member data // Static member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static const Color Black; ///< Black predefined color static const Color Black; ///< Black predefined color
static const Color White; ///< White predefined color static const Color White; ///< White predefined color
static const Color Red; ///< Red predefined color static const Color Red; ///< Red predefined color
static const Color Green; ///< Green predefined color static const Color Green; ///< Green predefined color
static const Color Blue; ///< Blue predefined color static const Color Blue; ///< Blue predefined color
static const Color Yellow; ///< Yellow predefined color static const Color Yellow; ///< Yellow predefined color
static const Color Magenta; ///< Magenta predefined color static const Color Magenta; ///< Magenta predefined color
static const Color Cyan; ///< Cyan predefined color static const Color Cyan; ///< Cyan predefined color
static const Color Transparent; ///< Transparent (black) predefined col
or
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Uint8 r; ///< Red component Uint8 r; ///< Red component
Uint8 g; ///< Green component Uint8 g; ///< Green component
Uint8 b; ///< Blue component Uint8 b; ///< Blue component
Uint8 a; ///< Alpha (transparency) component Uint8 a; ///< Alpha (opacity) component
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Operator + overload to add two colors /// \relates Color
/// \brief Overload of the == operator
///
/// This operator compares two colors and check if they are equal.
///
/// \param left Left operand
/// \param right Right operand
///
/// \return True if colors are equal, false if they are different
///
////////////////////////////////////////////////////////////
SFML_GRAPHICS_API bool operator ==(const Color& left, const Color& right);
////////////////////////////////////////////////////////////
/// \relates Color
/// \brief Overload of the != operator
///
/// This operator compares two colors and check if they are different.
///
/// \param left Left operand
/// \param right Right operand
///
/// \return True if colors are different, false if they are equal
///
////////////////////////////////////////////////////////////
SFML_GRAPHICS_API bool operator !=(const Color& left, const Color& right);
////////////////////////////////////////////////////////////
/// \relates Color
/// \brief Overload of the binary + operator
///
/// This operator returns the component-wise sum of two colors.
/// Components that exceed 255 are clamped to 255.
/// ///
/// \param Color1 : First color /// \param left Left operand
/// \param Color2 : Second color /// \param right Right operand
/// ///
/// \return Component-wise saturated addition of the two colors /// \return Result of \a left + \a right
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
SFML_API Color operator +(const Color& Color1, const Color& Color2); SFML_GRAPHICS_API Color operator +(const Color& left, const Color& right);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Operator * overload to modulate two colors /// \relates Color
/// \brief Overload of the binary * operator
/// ///
/// \param Color1 : First color /// This operator returns the component-wise multiplication
/// \param Color2 : Second color /// (also called "modulation") of two colors.
/// Components are then divided by 255 so that the result is
/// still in the range [0, 255].
/// ///
/// \return Component-wise multiplication of the two colors /// \param left Left operand
/// \param right Right operand
///
/// \return Result of \a left * \a right
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
SFML_API Color operator *(const Color& Color1, const Color& Color2); SFML_GRAPHICS_API Color operator *(const Color& left, const Color& right);
////////////////////////////////////////////////////////////
/// \relates Color
/// \brief Overload of the binary += operator
///
/// This operator computes the component-wise sum of two colors,
/// and assigns the result to the left operand.
/// Components that exceed 255 are clamped to 255.
///
/// \param left Left operand
/// \param right Right operand
///
/// \return Reference to \a left
///
////////////////////////////////////////////////////////////
SFML_GRAPHICS_API Color& operator +=(Color& left, const Color& right);
////////////////////////////////////////////////////////////
/// \relates Color
/// \brief Overload of the binary *= operator
///
/// This operator returns the component-wise multiplication
/// (also called "modulation") of two colors, and assigns
/// the result to the left operand.
/// Components are then divided by 255 so that the result is
/// still in the range [0, 255].
///
/// \param left Left operand
/// \param right Right operand
///
/// \return Reference to \a left
///
////////////////////////////////////////////////////////////
SFML_GRAPHICS_API Color& operator *=(Color& left, const Color& right);
} // namespace sf } // namespace sf
#endif // SFML_COLOR_HPP #endif // SFML_COLOR_HPP
////////////////////////////////////////////////////////////
/// \class sf::Color
/// \ingroup graphics
///
/// sf::Color is a simple color class composed of 4 components:
/// \li Red
/// \li Green
/// \li Blue
/// \li Alpha (opacity)
///
/// Each component is a public member, an unsigned integer in
/// the range [0, 255]. Thus, colors can be constructed and
/// manipulated very easily:
///
/// \code
/// sf::Color color(255, 0, 0); // red
/// color.r = 0; // make it black
/// color.b = 128; // make it dark blue
/// \endcode
///
/// The fourth component of colors, named "alpha", represents
/// the opacity of the color. A color with an alpha value of
/// 255 will be fully opaque, while an alpha value of 0 will
/// make a color fully transparent, whatever the value of the
/// other components is.
///
/// The most common colors are already defined as static variables:
/// \code
/// sf::Color black = sf::Color::Black;
/// sf::Color white = sf::Color::White;
/// sf::Color red = sf::Color::Red;
/// sf::Color green = sf::Color::Green;
/// sf::Color blue = sf::Color::Blue;
/// sf::Color yellow = sf::Color::Yellow;
/// sf::Color magenta = sf::Color::Magenta;
/// sf::Color cyan = sf::Color::Cyan;
/// sf::Color transparent = sf::Color::Transparent;
/// \endcode
///
/// Colors can also be added and modulated (multiplied) using the
/// overloaded operators + and *.
///
////////////////////////////////////////////////////////////
 End of changes. 21 change blocks. 
71 lines changed or deleted 108 lines changed or added


 Config.hpp   Config.hpp 
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// //
// SFML - Simple and Fast Multimedia Library // SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// //
// This software is provided 'as-is', without any express or implied warran ty. // This software is provided 'as-is', without any express or implied warran ty.
// In no event will the authors be held liable for any damages arising from the use of this software. // 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, // Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it f reely, // including commercial applications, and to alter it and redistribute it f reely,
// subject to the following restrictions: // subject to the following restrictions:
// //
// 1. The origin of this software must not be misrepresented; // 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software. // you must not claim that you wrote the original software.
skipping to change at line 29 skipping to change at line 29
// and must not be misrepresented as being the original software. // and must not be misrepresented as being the original software.
// //
// 3. This notice may not be removed or altered from any source distributio n. // 3. This notice may not be removed or altered from any source distributio n.
// //
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#ifndef SFML_CONFIG_HPP #ifndef SFML_CONFIG_HPP
#define SFML_CONFIG_HPP #define SFML_CONFIG_HPP
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Define the SFML version
////////////////////////////////////////////////////////////
#define SFML_VERSION_MAJOR 2
#define SFML_VERSION_MINOR 0
////////////////////////////////////////////////////////////
// Identify the operating system // Identify the operating system
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#if defined(_WIN32) || defined(__WIN32__) #if defined(_WIN32) || defined(__WIN32__)
// Windows // Windows
#define SFML_SYSTEM_WINDOWS #define SFML_SYSTEM_WINDOWS
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#ifndef NOMINMAX #ifndef NOMINMAX
#define NOMINMAX #define NOMINMAX
#endif #endif
#elif defined(linux) || defined(__linux) #elif defined(linux) || defined(__linux)
// Linux // Linux
#define SFML_SYSTEM_LINUX #define SFML_SYSTEM_LINUX
#elif defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || define d(Macintosh) #elif defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || define d(Macintosh)
skipping to change at line 74 skipping to change at line 77
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Define a portable debug macro // Define a portable debug macro
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#if !defined(NDEBUG) #if !defined(NDEBUG)
#define SFML_DEBUG #define SFML_DEBUG
#endif #endif
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Define portable import / export macros // Define helpers to create portable import / export macros for each module
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#if defined(SFML_SYSTEM_WINDOWS) #if !defined(SFML_STATIC)
#ifdef SFML_DYNAMIC
// Windows platforms #if defined(SFML_SYSTEM_WINDOWS)
#ifdef SFML_EXPORTS
// From DLL side, we must export // Windows compilers need specific (and different) keywords for exp
#define SFML_API __declspec(dllexport) ort and import
#define SFML_API_EXPORT __declspec(dllexport)
#define SFML_API_IMPORT __declspec(dllimport)
#else // For Visual C++ compilers, we also need to turn off this annoying
C4251 warning
#ifdef _MSC_VER
// From client application side, we must import #pragma warning(disable : 4251)
#define SFML_API __declspec(dllimport)
#endif #endif
// For Visual C++ compilers, we also need to turn off this annoying #else // Linux, FreeBSD, Mac OS X
C4251 warning.
// You can read lots ot different things about it, but the point is
the code will
// just work fine, and so the simplest way to get rid of this warni
ng is to disable it
#ifdef _MSC_VER
#pragma warning(disable : 4251) #if __GNUC__ >= 4
#endif // GCC 4 has special keywords for showing/hidding symbols,
// the same keyword is used for both importing and exporting
#define SFML_API_EXPORT __attribute__ ((__visibility__ ("defaul
t")))
#define SFML_API_IMPORT __attribute__ ((__visibility__ ("defaul
t")))
#else #else
// GCC < 4 has no mechanism to explicitely hide symbols, everyt
hing's exported
#define SFML_API_EXPORT
#define SFML_API_IMPORT
// No specific directive needed for static build #endif
#define SFML_API
#endif #endif
#else #else
// Other platforms don't need to define anything // Static build doesn't need import/export macros
#define SFML_API #define SFML_API_EXPORT
#define SFML_API_IMPORT
#endif #endif
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Define portable fixed-size types // Define portable fixed-size types
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <climits>
namespace sf namespace sf
{ {
// All "common" platforms use the same size for char, short and int
// (basically there are 3 types for 3 sizes, so no other match is possi
ble),
// we can use them without doing any kind of check
// 8 bits integer types // 8 bits integer types
#if UCHAR_MAX == 0xFF typedef signed char Int8;
typedef signed char Int8; typedef unsigned char Uint8;
typedef unsigned char Uint8;
#else
#error No 8 bits integer type for this platform
#endif
// 16 bits integer types // 16 bits integer types
#if USHRT_MAX == 0xFFFF typedef signed short Int16;
typedef signed short Int16; typedef unsigned short Uint16;
typedef unsigned short Uint16;
#elif UINT_MAX == 0xFFFF
typedef signed int Int16;
typedef unsigned int Uint16;
#elif ULONG_MAX == 0xFFFF
typedef signed long Int16;
typedef unsigned long Uint16;
#else
#error No 16 bits integer type for this platform
#endif
// 32 bits integer types // 32 bits integer types
#if USHRT_MAX == 0xFFFFFFFF typedef signed int Int32;
typedef signed short Int32; typedef unsigned int Uint32;
typedef unsigned short Uint32;
#elif UINT_MAX == 0xFFFFFFFF // 64 bits integer types
typedef signed int Int32; #if defined(_MSC_VER)
typedef unsigned int Uint32; typedef signed __int64 Int64;
#elif ULONG_MAX == 0xFFFFFFFF typedef unsigned __int64 Uint64;
typedef signed long Int32;
typedef unsigned long Uint32;
#else #else
#error No 32 bits integer type for this platform typedef signed long long Int64;
typedef unsigned long long Uint64;
#endif #endif
} // namespace sf } // namespace sf
#endif // SFML_CONFIG_HPP #endif // SFML_CONFIG_HPP
 End of changes. 21 change blocks. 
59 lines changed or deleted 54 lines changed or added


 Context.hpp   Context.hpp 
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// //
// SFML - Simple and Fast Multimedia Library // SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// //
// This software is provided 'as-is', without any express or implied warran ty. // This software is provided 'as-is', without any express or implied warran ty.
// In no event will the authors be held liable for any damages arising from the use of this software. // 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, // Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it f reely, // including commercial applications, and to alter it and redistribute it f reely,
// subject to the following restrictions: // subject to the following restrictions:
// //
// 1. The origin of this software must not be misrepresented; // 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software. // you must not claim that you wrote the original software.
skipping to change at line 31 skipping to change at line 31
// 3. This notice may not be removed or altered from any source distributio n. // 3. This notice may not be removed or altered from any source distributio n.
// //
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#ifndef SFML_CONTEXT_HPP #ifndef SFML_CONTEXT_HPP
#define SFML_CONTEXT_HPP #define SFML_CONTEXT_HPP
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Config.hpp> #include <SFML/Window/Export.hpp>
#include <SFML/Window/GlResource.hpp>
#include <SFML/Window/ContextSettings.hpp>
#include <SFML/System/NonCopyable.hpp> #include <SFML/System/NonCopyable.hpp>
namespace sf namespace sf
{ {
namespace priv namespace priv
{ {
class WindowImpl; class GlContext;
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Class wrapping an OpenGL context. /// \brief Class holding a valid drawing context
/// All SFML windows already have their own context, so ///
/// this class is more a helper for specific issues involving
/// OpenGL and multi-threading.
/// It's meant to be used internally.
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class SFML_API Context : NonCopyable class SFML_WINDOW_API Context : GlResource, NonCopyable
{ {
public : public :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Default constructor, create the context /// \brief Default constructor
///
/// The constructor creates and activates the context
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Context(); Context();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destructor, destroy the context /// \brief Destructor
///
/// The desctructor deactivates and destroys the context
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
~Context(); ~Context();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Activate or deactivate the context /// \brief Activate or deactivate explicitely the context
///
/// \param Active : True to activate the context, false to deactivate i
t
/// ///
//////////////////////////////////////////////////////////// /// \param active True to activate, false to deactivate
void SetActive(bool Active);
////////////////////////////////////////////////////////////
/// Check if there's a context bound to the current thread
/// ///
/// \return True if there's a context bound to the current thread /// \return True on success, false on failure
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static bool IsContextActive(); bool setActive(bool active);
public :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the global context /// \brief Construct a in-memory context
///
/// This constructor is for internal use, you don't need
/// to bother with it.
/// ///
/// \return Reference to the global context /// \param settings Creation parameters
/// \param width Back buffer width
/// \param height Back buffer height
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static Context& GetGlobal(); Context(const ContextSettings& settings, unsigned int width, unsigned i nt height);
private : private :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
priv::WindowImpl* myDummyWindow; ///< Dummy window holding the context priv::GlContext* m_context; ///< Internal OpenGL context
}; };
} // namespace sf } // namespace sf
#endif // SFML_CONTEXT_HPP #endif // SFML_CONTEXT_HPP
////////////////////////////////////////////////////////////
/// \class sf::Context
/// \ingroup window
///
/// If you need to make OpenGL calls without having an
/// active window (like in a thread), you can use an
/// instance of this class to get a valid context.
///
/// Having a valid context is necessary for *every* OpenGL call.
///
/// Note that a context is only active in its current thread,
/// if you create a new thread it will have no valid context
/// by default.
///
/// To use a sf::Context instance, just construct it and let it
/// live as long as you need a valid context. No explicit activation
/// is needed, all it has to do is to exist. Its destructor
/// will take care of deactivating and freeing all the attached
/// resources.
///
/// Usage example:
/// \code
/// void threadFunction(void*)
/// {
/// sf::Context context;
/// // from now on, you have a valid context
///
/// // you can make OpenGL calls
/// glClear(GL_DEPTH_BUFFER_BIT);
/// }
/// // the context is automatically deactivated and destroyed
/// // by the sf::Context destructor
/// \endcode
///
////////////////////////////////////////////////////////////
 End of changes. 16 change blocks. 
26 lines changed or deleted 29 lines changed or added


 Drawable.hpp   Drawable.hpp 
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// //
// SFML - Simple and Fast Multimedia Library // SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// //
// This software is provided 'as-is', without any express or implied warran ty. // This software is provided 'as-is', without any express or implied warran ty.
// In no event will the authors be held liable for any damages arising from the use of this software. // 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, // Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it f reely, // including commercial applications, and to alter it and redistribute it f reely,
// subject to the following restrictions: // subject to the following restrictions:
// //
// 1. The origin of this software must not be misrepresented; // 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software. // you must not claim that you wrote the original software.
skipping to change at line 31 skipping to change at line 31
// 3. This notice may not be removed or altered from any source distributio n. // 3. This notice may not be removed or altered from any source distributio n.
// //
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#ifndef SFML_DRAWABLE_HPP #ifndef SFML_DRAWABLE_HPP
#define SFML_DRAWABLE_HPP #define SFML_DRAWABLE_HPP
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/System/Vector2.hpp> #include <SFML/Graphics/Export.hpp>
#include <SFML/Graphics/Color.hpp> #include <SFML/Graphics/RenderStates.hpp>
#include <SFML/Graphics/Matrix3.hpp>
namespace sf namespace sf
{ {
class RenderTarget; class RenderTarget;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Enumerate the blending modes for drawable objects /// \brief Abstract base class for objects that can be drawn
/// to a render target
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
namespace Blend class SFML_GRAPHICS_API Drawable
{
enum Mode
{
Alpha, ///< Pixel = Src * a + Dest * (1 - a)
Add, ///< Pixel = Src + Dest
Multiply, ///< Pixel = Src * Dest
None ///< No blending
};
}
////////////////////////////////////////////////////////////
/// Abstract base class for every object that can be drawn
/// into a render window
////////////////////////////////////////////////////////////
class SFML_API Drawable
{ {
public : public :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Default constructor /// \brief Virtual destructor
///
/// \param Position : Position of the object (0, 0 by default)
/// \param Scale : Scale factor (1, 1 by default)
/// \param Rotation : Orientation, in degrees (0 by default)
/// \param Col : Color of the object (white by default)
///
////////////////////////////////////////////////////////////
Drawable(const Vector2f& Position = Vector2f(0, 0), const Vector2f& Sca
le = Vector2f(1, 1), float Rotation = 0.f, const Color& Col = Color(255, 25
5, 255, 255));
////////////////////////////////////////////////////////////
/// Virtual destructor
///
////////////////////////////////////////////////////////////
virtual ~Drawable();
////////////////////////////////////////////////////////////
/// Set the position of the object (take 2 values)
///
/// \param X : New X coordinate
/// \param Y : New Y coordinate
///
////////////////////////////////////////////////////////////
void SetPosition(float X, float Y);
////////////////////////////////////////////////////////////
/// Set the position of the object (take a 2D vector)
///
/// \param Position : New position
///
////////////////////////////////////////////////////////////
void SetPosition(const Vector2f& Position);
////////////////////////////////////////////////////////////
/// Set the X position of the object
///
/// \param X : New X coordinate
///
////////////////////////////////////////////////////////////
void SetX(float X);
////////////////////////////////////////////////////////////
/// Set the Y position of the object
///
/// \param Y : New Y coordinate
///
////////////////////////////////////////////////////////////
void SetY(float Y);
////////////////////////////////////////////////////////////
/// Set the scale of the object (take 2 values)
///
/// \param ScaleX : New horizontal scale (must be strictly positive)
/// \param ScaleY : New vertical scale (must be strictly positive)
///
////////////////////////////////////////////////////////////
void SetScale(float ScaleX, float ScaleY);
////////////////////////////////////////////////////////////
/// Set the scale of the object (take a 2D vector)
///
/// \param Scale : New scale (both values must be strictly positive)
///
////////////////////////////////////////////////////////////
void SetScale(const Vector2f& Scale);
////////////////////////////////////////////////////////////
/// Set the X scale factor of the object
///
/// \param X : New X scale factor
///
////////////////////////////////////////////////////////////
void SetScaleX(float FactorX);
////////////////////////////////////////////////////////////
/// Set the Y scale factor of the object
///
/// \param Y : New Y scale factor
///
////////////////////////////////////////////////////////////
void SetScaleY(float FactorY);
////////////////////////////////////////////////////////////
/// Set the center of the object, in coordinates relative to the
/// top-left of the object (take 2 values).
/// The default center is (0, 0)
///
/// \param CenterX : X coordinate of the center
/// \param CenterY : Y coordinate of the center
///
////////////////////////////////////////////////////////////
void SetCenter(float CenterX, float CenterY);
////////////////////////////////////////////////////////////
/// Set the center of the object, in coordinates relative to the
/// top-left of the object (take a 2D vector).
/// The default center is (0, 0)
///
/// \param Center : New center
///
////////////////////////////////////////////////////////////
void SetCenter(const Vector2f& Center);
////////////////////////////////////////////////////////////
/// Set the orientation of the object
///
/// \param Rotation : Angle of rotation, in degrees
///
////////////////////////////////////////////////////////////
void SetRotation(float Rotation);
////////////////////////////////////////////////////////////
/// Set the color of the object.
/// The default color is white
///
/// \param Col : New color
///
////////////////////////////////////////////////////////////
void SetColor(const Color& Col);
////////////////////////////////////////////////////////////
/// Set the blending mode for the object.
/// The default blend mode is Blend::Alpha
///
/// \param Mode : New blending mode
///
////////////////////////////////////////////////////////////
void SetBlendMode(Blend::Mode Mode);
////////////////////////////////////////////////////////////
/// Get the position of the object
///
/// \return Current position
///
////////////////////////////////////////////////////////////
const Vector2f& GetPosition() const;
////////////////////////////////////////////////////////////
/// Get the current scale of the object
///
/// \return Current scale factor (always positive)
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const Vector2f& GetScale() const; virtual ~Drawable() {}
////////////////////////////////////////////////////////////
/// Get the center of the object
///
/// \return Current position of the center
///
////////////////////////////////////////////////////////////
const Vector2f& GetCenter() const;
////////////////////////////////////////////////////////////
/// Get the orientation of the object.
/// Rotation is always in the range [0, 360]
///
/// \return Current rotation, in degrees
///
////////////////////////////////////////////////////////////
float GetRotation() const;
////////////////////////////////////////////////////////////
/// Get the color of the object
///
/// \return Current color
///
////////////////////////////////////////////////////////////
const Color& GetColor() const;
////////////////////////////////////////////////////////////
/// Get the current blending mode
///
/// \return Current blending mode
///
////////////////////////////////////////////////////////////
Blend::Mode GetBlendMode() const;
////////////////////////////////////////////////////////////
/// Move the object of a given offset (take 2 values)
///
/// \param OffsetX : X offset
/// \param OffsetY : Y offset
///
////////////////////////////////////////////////////////////
void Move(float OffsetX, float OffsetY);
////////////////////////////////////////////////////////////
/// Move the object of a given offset (take a 2D vector)
///
/// \param Offset : Amount of units to move the object of
///
////////////////////////////////////////////////////////////
void Move(const Vector2f& Offset);
////////////////////////////////////////////////////////////
/// Scale the object (take 2 values)
///
/// \param FactorX : Scaling factor on X (must be strictly positive)
/// \param FactorY : Scaling factor on Y (must be strictly positive)
///
////////////////////////////////////////////////////////////
void Scale(float FactorX, float FactorY);
////////////////////////////////////////////////////////////
/// Scale the object (take a 2D vector)
///
/// \param Factor : Scaling factors (both values must be strictly posit
ive)
///
////////////////////////////////////////////////////////////
void Scale(const Vector2f& Factor);
////////////////////////////////////////////////////////////
/// Rotate the object
///
/// \param Angle : Angle of rotation, in degrees
///
////////////////////////////////////////////////////////////
void Rotate(float Angle);
////////////////////////////////////////////////////////////
/// Transform a point from global coordinates into local coordinates
/// (ie it applies the inverse of object's center, translation, rotatio
n and scale to the point)
///
/// \param Point : Point to transform
///
/// \return Transformed point
///
////////////////////////////////////////////////////////////
sf::Vector2f TransformToLocal(const sf::Vector2f& Point) const;
////////////////////////////////////////////////////////////
/// Transform a point from local coordinates into global coordinates
/// (ie it applies the object's center, translation, rotation and scale
to the point)
///
/// \param Point : Point to transform
///
/// \return Transformed point
///
////////////////////////////////////////////////////////////
sf::Vector2f TransformToGlobal(const sf::Vector2f& Point) const;
protected : protected :
////////////////////////////////////////////////////////////
/// Get the transform matrix of the drawable
///
/// \return Transform matrix
///
////////////////////////////////////////////////////////////
const Matrix3& GetMatrix() const;
////////////////////////////////////////////////////////////
/// Get the inverse transform matrix of the drawable
///
/// \return Inverse transform matrix
///
////////////////////////////////////////////////////////////
const Matrix3& GetInverseMatrix() const;
private :
friend class RenderTarget; friend class RenderTarget;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Draw the object into the specified window /// \brief Draw the object to a render target
/// ///
/// \param Target : Target into which render the object /// This is a pure virtual function that has to be implemented
/// by the derived class to define how the drawable should be
/// drawn.
/// ///
//////////////////////////////////////////////////////////// /// \param target Render target to draw to
void Draw(RenderTarget& Target) const; /// \param states Current render states
////////////////////////////////////////////////////////////
/// Render the specific geometry of the object
/// ///
/// \param Target : Target into which render the object
///
////////////////////////////////////////////////////////////
virtual void Render(RenderTarget& Target) const = 0;
////////////////////////////////////////////////////////////
// Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Vector2f myPosition; ///< Position of the object on screen virtual void draw(RenderTarget& target, RenderStates states) const = 0;
Vector2f myScale; ///< Scale of the object
Vector2f myCenter; ///< Origin of translation / rotation
/ scaling of the object
float myRotation; ///< Orientation of the object, in deg
rees
Color myColor; ///< Overlay color of the object
Blend::Mode myBlendMode; ///< Blending mode
mutable bool myNeedUpdate; ///< Do we need to recompute the trans
form matrix ?
mutable bool myInvNeedUpdate; ///< Do we need to recompute the inver
se transform matrix ?
mutable Matrix3 myMatrix; ///< Precomputed transform matrix gath
ering the translation / rotation / scale / center
mutable Matrix3 myInvMatrix; ///< Precomputed inverse transform mat
rix gathering the translation / rotation / scale / center
}; };
} // namespace sf } // namespace sf
#endif // SFML_DRAWABLE_HPP #endif // SFML_DRAWABLE_HPP
////////////////////////////////////////////////////////////
/// \class sf::Drawable
/// \ingroup graphics
///
/// sf::Drawable is a very simple base class that allows objects
/// of derived classes to be drawn to a sf::RenderTarget.
///
/// All you have to do in your derived class is to override the
/// draw virtual function.
///
/// Note that inheriting from sf::Drawable is not mandatory,
/// but it allows this nice syntax "window.draw(object)" rather
/// than "object.draw(window)", which is more consistent with other
/// SFML classes.
///
/// Example:
/// \code
/// class MyDrawable : public sf::Drawable
/// {
/// public :
///
/// ...
///
/// private :
///
/// virtual void draw(sf::RenderTarget& target, sf::RenderStates states
) const
/// {
/// // You can draw other high-level objects
/// target.draw(m_sprite, states);
///
/// // ... or use the low-level API
/// states.texture = &m_texture;
/// target.draw(m_vertices, states);
///
/// // ... or draw with OpenGL directly
/// glBegin(GL_QUADS);
/// ...
/// glEnd();
/// }
///
/// sf::Sprite m_sprite;
/// sf::Texture m_texture;
/// sf::VertexArray m_vertices;
/// };
/// \endcode
///
/// \see sf::RenderTarget
///
////////////////////////////////////////////////////////////
 End of changes. 13 change blocks. 
313 lines changed or deleted 16 lines changed or added


 Event.hpp   Event.hpp 
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// //
// SFML - Simple and Fast Multimedia Library // SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// //
// This software is provided 'as-is', without any express or implied warran ty. // This software is provided 'as-is', without any express or implied warran ty.
// In no event will the authors be held liable for any damages arising from the use of this software. // 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, // Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it f reely, // including commercial applications, and to alter it and redistribute it f reely,
// subject to the following restrictions: // subject to the following restrictions:
// //
// 1. The origin of this software must not be misrepresented; // 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software. // you must not claim that you wrote the original software.
skipping to change at line 32 skipping to change at line 32
// //
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#ifndef SFML_EVENT_HPP #ifndef SFML_EVENT_HPP
#define SFML_EVENT_HPP #define SFML_EVENT_HPP
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Config.hpp> #include <SFML/Config.hpp>
#include <SFML/Window/Joystick.hpp>
#include <SFML/Window/Keyboard.hpp>
#include <SFML/Window/Mouse.hpp>
namespace sf namespace sf
{ {
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Definition of key codes for keyboard events /// \brief Defines a system event and its parameters
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
namespace Key class Event
{
enum Code
{
A = 'a',
B = 'b',
C = 'c',
D = 'd',
E = 'e',
F = 'f',
G = 'g',
H = 'h',
I = 'i',
J = 'j',
K = 'k',
L = 'l',
M = 'm',
N = 'n',
O = 'o',
P = 'p',
Q = 'q',
R = 'r',
S = 's',
T = 't',
U = 'u',
V = 'v',
W = 'w',
X = 'x',
Y = 'y',
Z = 'z',
Num0 = '0',
Num1 = '1',
Num2 = '2',
Num3 = '3',
Num4 = '4',
Num5 = '5',
Num6 = '6',
Num7 = '7',
Num8 = '8',
Num9 = '9',
Escape = 256,
LControl,
LShift,
LAlt,
LSystem, ///< OS specific key (left side) : windows (Win and L
inux), apple (MacOS), ...
RControl,
RShift,
RAlt,
RSystem, ///< OS specific key (right side) : windows (Win and
Linux), apple (MacOS), ...
Menu,
LBracket, ///< [
RBracket, ///< ]
SemiColon, ///< ;
Comma, ///< ,
Period, ///< .
Quote, ///< '
Slash, ///< /
BackSlash,
Tilde, ///< ~
Equal, ///< =
Dash, ///< -
Space,
Return,
Back,
Tab,
PageUp,
PageDown,
End,
Home,
Insert,
Delete,
Add, ///< +
Subtract, ///< -
Multiply, ///< *
Divide, ///< /
Left, ///< Left arrow
Right, ///< Right arrow
Up, ///< Up arrow
Down, ///< Down arrow
Numpad0,
Numpad1,
Numpad2,
Numpad3,
Numpad4,
Numpad5,
Numpad6,
Numpad7,
Numpad8,
Numpad9,
F1,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
F11,
F12,
F13,
F14,
F15,
Pause,
Count // Keep last -- total number of keyboard keys
};
}
////////////////////////////////////////////////////////////
/// Definition of button codes for mouse events
////////////////////////////////////////////////////////////
namespace Mouse
{
enum Button
{
Left,
Right,
Middle,
XButton1,
XButton2,
ButtonCount // Keep last -- total number of mouse buttons
};
}
////////////////////////////////////////////////////////////
/// Definition of joystick axis for joystick events
////////////////////////////////////////////////////////////
namespace Joy
{ {
enum Axis public :
{
AxisX,
AxisY,
AxisZ,
AxisR,
AxisU,
AxisV,
AxisPOV,
AxisCount // Keep last -- total number of joystick axis
};
enum ////////////////////////////////////////////////////////////
/// \brief Size events parameters (Resized)
///
////////////////////////////////////////////////////////////
struct SizeEvent
{ {
Count = 4, ///< Total number of supported joysticks unsigned int width; ///< New width, in pixels
ButtonCount = 32 ///< Total number of supported joystick buttons unsigned int height; ///< New height, in pixels
}; };
}
////////////////////////////////////////////////////////////
/// Event defines a system event and its parameters
////////////////////////////////////////////////////////////
class Event
{
public :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Keyboard event parameters /// \brief Keyboard event parameters (KeyPressed, KeyReleased)
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
struct KeyEvent struct KeyEvent
{ {
Key::Code Code; Keyboard::Key code; ///< Code of the key that has been pressed
bool Alt; bool alt; ///< Is the Alt key pressed?
bool Control; bool control; ///< Is the Control key pressed?
bool Shift; bool shift; ///< Is the Shift key pressed?
bool system; ///< Is the System key pressed?
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Text event parameters /// \brief Text event parameters (TextEntered)
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
struct TextEvent struct TextEvent
{ {
Uint32 Unicode; Uint32 unicode; ///< UTF-32 unicode value of the character
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Mouse move event parameters /// \brief Mouse move event parameters (MouseMoved)
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
struct MouseMoveEvent struct MouseMoveEvent
{ {
int X; int x; ///< X position of the mouse pointer, relative to the left o
int Y; f the owner window
int y; ///< Y position of the mouse pointer, relative to the top of
the owner window
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Mouse buttons events parameters /// \brief Mouse buttons events parameters
/// (MouseButtonPressed, MouseButtonReleased)
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
struct MouseButtonEvent struct MouseButtonEvent
{ {
Mouse::Button Button; Mouse::Button button; ///< Code of the button that has been pressed
int X; int x; ///< X position of the mouse pointer, relativ
int Y; e to the left of the owner window
int y; ///< Y position of the mouse pointer, relativ
e to the top of the owner window
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Mouse wheel events parameters /// \brief Mouse wheel events parameters (MouseWheelMoved)
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
struct MouseWheelEvent struct MouseWheelEvent
{ {
int Delta; int delta; ///< Number of ticks the wheel has moved (positive is up
, negative is down)
int x; ///< X position of the mouse pointer, relative to the le
ft of the owner window
int y; ///< Y position of the mouse pointer, relative to the to
p of the owner window
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Joystick axis move event parameters /// \brief Joystick connection events parameters
/// (JoystickConnected, JoystickDisconnected)
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
struct JoyMoveEvent struct JoystickConnectEvent
{ {
unsigned int JoystickId; unsigned int joystickId; ///< Index of the joystick (in range [0 ..
Joy::Axis Axis; Joystick::Count - 1])
float Position;
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Joystick buttons events parameters /// \brief Joystick axis move event parameters (JoystickMoved)
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
struct JoyButtonEvent struct JoystickMoveEvent
{ {
unsigned int JoystickId; unsigned int joystickId; ///< Index of the joystick (in range [0
unsigned int Button; .. Joystick::Count - 1])
Joystick::Axis axis; ///< Axis on which the joystick moved
float position; ///< New position on the axis (in range
[-100 .. 100])
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Size events parameters /// \brief Joystick buttons events parameters
/// (JoystickButtonPressed, JoystickButtonReleased)
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
struct SizeEvent struct JoystickButtonEvent
{ {
unsigned int Width; unsigned int joystickId; ///< Index of the joystick (in range [0 ..
unsigned int Height; Joystick::Count - 1])
unsigned int button; ///< Index of the button that has been pre
ssed (in range [0 .. Joystick::ButtonCount - 1])
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Enumeration of the different types of events /// \brief Enumeration of the different types of events
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
enum EventType enum EventType
{ {
Closed, Closed, ///< The window requested to be closed (no
Resized, data)
LostFocus, Resized, ///< The window was resized (data in event.
GainedFocus, size)
TextEntered, LostFocus, ///< The window lost the focus (no data)
KeyPressed, GainedFocus, ///< The window gained the focus (no data)
KeyReleased, TextEntered, ///< A character was entered (data in event
MouseWheelMoved, .text)
MouseButtonPressed, KeyPressed, ///< A key was pressed (data in event.key)
MouseButtonReleased, KeyReleased, ///< A key was released (data in event.key)
MouseMoved, MouseWheelMoved, ///< The mouse wheel was scrolled (data in
MouseEntered, event.mouseWheel)
MouseLeft, MouseButtonPressed, ///< A mouse button was pressed (data in ev
JoyButtonPressed, ent.mouseButton)
JoyButtonReleased, MouseButtonReleased, ///< A mouse button was released (data in e
JoyMoved, vent.mouseButton)
MouseMoved, ///< The mouse cursor moved (data in event.
mouseMove)
MouseEntered, ///< The mouse cursor entered the area of t
he window (no data)
MouseLeft, ///< The mouse cursor left the area of the
window (no data)
JoystickButtonPressed, ///< A joystick button was pressed (data in
event.joystickButton)
JoystickButtonReleased, ///< A joystick button was released (data i
n event.joystickButton)
JoystickMoved, ///< The joystick moved along an axis (data
in event.joystickMove)
JoystickConnected, ///< A joystick was connected (data in even
t.joystickConnect)
JoystickDisconnected, ///< A joystick was disconnected (data in e
vent.joystickConnect)
Count // Keep last -- total number of event types Count ///< Keep last -- the total number of event types
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
EventType Type; ///< Type of the event EventType type; ///< Type of the event
union union
{ {
KeyEvent Key; SizeEvent size; ///< Size event parameters (E
TextEvent Text; vent::Resized)
MouseMoveEvent MouseMove; KeyEvent key; ///< Key event parameters (Ev
MouseButtonEvent MouseButton; ent::KeyPressed, Event::KeyReleased)
MouseWheelEvent MouseWheel; TextEvent text; ///< Text event parameters (E
JoyMoveEvent JoyMove; vent::TextEntered)
JoyButtonEvent JoyButton; MouseMoveEvent mouseMove; ///< Mouse move event paramet
SizeEvent Size; ers (Event::MouseMoved)
MouseButtonEvent mouseButton; ///< Mouse button event param
eters (Event::MouseButtonPressed, Event::MouseButtonReleased)
MouseWheelEvent mouseWheel; ///< Mouse wheel event parame
ters (Event::MouseWheelMoved)
JoystickMoveEvent joystickMove; ///< Joystick move event para
meters (Event::JoystickMoved)
JoystickButtonEvent joystickButton; ///< Joystick button event pa
rameters (Event::JoystickButtonPressed, Event::JoystickButtonReleased)
JoystickConnectEvent joystickConnect; ///< Joystick (dis)connect ev
ent parameters (Event::JoystickConnected, Event::JoystickDisconnected)
}; };
}; };
} // namespace sf } // namespace sf
#endif // SFML_EVENT_HPP #endif // SFML_EVENT_HPP
////////////////////////////////////////////////////////////
/// \class sf::Event
/// \ingroup window
///
/// sf::Event holds all the informations about a system event
/// that just happened. Events are retrieved using the
/// sf::Window::pollEvent and sf::Window::waitEvent functions.
///
/// A sf::Event instance contains the type of the event
/// (mouse moved, key pressed, window closed, ...) as well
/// as the details about this particular event. Please note that
/// the event parameters are defined in a union, which means that
/// only the member matching the type of the event will be properly
/// filled; all other members will have undefined values and must not
/// be read if the type of the event doesn't match. For example,
/// if you received a KeyPressed event, then you must read the
/// event.key member, all other members such as event.MouseMove
/// or event.text will have undefined values.
///
/// Usage example:
/// \code
/// sf::Event event;
/// while (window.pollEvent(event))
/// {
/// // Request for closing the window
/// if (event.type == sf::Event::Closed)
/// window.close();
///
/// // The escape key was pressed
/// if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf:
:Keyboard::Escape))
/// window.close();
///
/// // The window was resized
/// if (event.type == sf::Event::Resized)
/// doSomethingWithTheNewSize(event.size.width, event.size.height);
///
/// // etc ...
/// }
/// \endcode
///
////////////////////////////////////////////////////////////
 End of changes. 33 change blocks. 
214 lines changed or deleted 123 lines changed or added


 Font.hpp   Font.hpp 
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// //
// SFML - Simple and Fast Multimedia Library // SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// //
// This software is provided 'as-is', without any express or implied warran ty. // This software is provided 'as-is', without any express or implied warran ty.
// In no event will the authors be held liable for any damages arising from the use of this software. // 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, // Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it f reely, // including commercial applications, and to alter it and redistribute it f reely,
// subject to the following restrictions: // subject to the following restrictions:
// //
// 1. The origin of this software must not be misrepresented; // 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software. // you must not claim that you wrote the original software.
skipping to change at line 31 skipping to change at line 31
// 3. This notice may not be removed or altered from any source distributio n. // 3. This notice may not be removed or altered from any source distributio n.
// //
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#ifndef SFML_FONT_HPP #ifndef SFML_FONT_HPP
#define SFML_FONT_HPP #define SFML_FONT_HPP
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/System/Resource.hpp> #include <SFML/Graphics/Export.hpp>
#include <SFML/System/Vector2.hpp>
#include <SFML/System/Unicode.hpp>
#include <SFML/Graphics/Glyph.hpp> #include <SFML/Graphics/Glyph.hpp>
#include <SFML/Graphics/Image.hpp> #include <SFML/Graphics/Texture.hpp>
#include <SFML/Graphics/Rect.hpp> #include <SFML/Graphics/Rect.hpp>
#include <SFML/System/Vector2.hpp>
#include <SFML/System/String.hpp>
#include <map> #include <map>
#include <string> #include <string>
#include <vector>
namespace sf namespace sf
{ {
class String; class InputStream;
namespace priv
{
class FontLoader;
}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Font is the low-level class for loading and /// \brief Class for loading and manipulating character fonts
/// manipulating character fonts. This class is meant to ///
/// be used by sf::String
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class SFML_API Font : public Resource<Font> class SFML_GRAPHICS_API Font
{ {
public : public :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Default constructor /// \brief Default constructor
///
/// This constructor defines an empty font
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Font(); Font();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Load the font from a file /// \brief Copy constructor
///
/// \param copy Instance to copy
///
////////////////////////////////////////////////////////////
Font(const Font& copy);
////////////////////////////////////////////////////////////
/// \brief Destructor
///
/// Cleans up all the internal resources used by the font
///
////////////////////////////////////////////////////////////
~Font();
////////////////////////////////////////////////////////////
/// \brief Load the font from a file
///
/// The supported font formats are: TrueType, Type 1, CFF,
/// OpenType, SFNT, X11 PCF, Windows FNT, BDF, PFR and Type 42.
/// Note that this function know nothing about the standard
/// fonts installed on the user's system, thus you can't
/// load them directly.
///
/// \param filename Path of the font file to load
///
/// \return True if loading succeeded, false if it failed
///
/// \see loadFromMemory, loadFromStream
///
////////////////////////////////////////////////////////////
bool loadFromFile(const std::string& filename);
////////////////////////////////////////////////////////////
/// \brief Load the font from a file in memory
///
/// The supported font formats are: TrueType, Type 1, CFF,
/// OpenType, SFNT, X11 PCF, Windows FNT, BDF, PFR and Type 42.
/// Warning: SFML cannot preload all the font data in this
/// function, so the buffer pointed by \a data has to remain
/// valid as long as the font is used.
///
/// \param data Pointer to the file data in memory
/// \param sizeInBytes Size of the data to load, in bytes
/// ///
/// \param Filename : Font file to load /// \return True if loading succeeded, false if it failed
/// \param CharSize : Size of characters in bitmap - the bigger, the hi
gher quality (30 by default)
/// \param Charset : Characters set to generate (by default, contains
the ISO-8859-1 printable characters)
/// ///
/// \return True if loading was successful /// \see loadFromFile, loadFromStream
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
bool LoadFromFile(const std::string& Filename, unsigned int CharSize = 30, const Unicode::Text& Charset = ourDefaultCharset); bool loadFromMemory(const void* data, std::size_t sizeInBytes);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Load the font from a file in memory /// \brief Load the font from a custom stream
/// ///
/// \param Data : Pointer to the data to load /// The supported font formats are: TrueType, Type 1, CFF,
/// \param SizeInBytes : Size of the data, in bytes /// OpenType, SFNT, X11 PCF, Windows FNT, BDF, PFR and Type 42.
/// \param CharSize : Size of characters in bitmap - the bigger, the /// Warning: SFML cannot preload all the font data in this
higher quality (30 by default) /// function, so the contents of \a stream have to remain
/// \param Charset : Characters set to generate (by default, contai /// valid as long as the font is used.
ns the ISO-8859-1 printable characters)
/// ///
/// \return True if loading was successful /// \param stream Source stream to read from
///
/// \return True if loading succeeded, false if it failed
///
/// \see loadFromFile, loadFromMemory
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
bool LoadFromMemory(const char* Data, std::size_t SizeInBytes, unsigned int CharSize = 30, const Unicode::Text& Charset = ourDefaultCharset); bool loadFromStream(InputStream& stream);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the base size of characters in the font; /// \brief Retrieve a glyph of the font
/// All glyphs dimensions are based on this value ///
/// \param codePoint Unicode code point of the character to get
/// \param characterSize Reference character size
/// \param bold Retrieve the bold version or the regular one?
/// ///
/// \return Base size of characters /// \return The glyph corresponding to \a codePoint and \a characterSiz e
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
unsigned int GetCharacterSize() const; const Glyph& getGlyph(Uint32 codePoint, unsigned int characterSize, boo l bold) const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the description of a glyph (character) /// \brief Get the kerning offset of two glyphs
/// given by its unicode value
/// ///
/// \param CodePoint : Unicode value of the character to get /// The kerning is an extra offset (negative) to apply between two
/// glyphs when rendering them, to make the pair look more "natural".
/// For example, the pair "AV" have a special kerning to make them
/// closer than other characters. Most of the glyphs pairs have a
/// kerning offset of zero, though.
/// ///
/// \return Glyph's visual settings, or an invalid glyph if character n /// \param first Unicode code point of the first character
ot found /// \param second Unicode code point of the second character
/// \param characterSize Reference character size
///
/// \return Kerning value for \a first and \a second, in pixels
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const Glyph& GetGlyph(Uint32 CodePoint) const; int getKerning(Uint32 first, Uint32 second, unsigned int characterSize) const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the image containing the rendered characters (glyphs) /// \brief Get the line spacing
///
/// Line spacing is the vertical offset to apply between two
/// consecutive lines of text.
/// ///
/// \return Image containing glyphs /// \param characterSize Reference character size
///
/// \return Line spacing, in pixels
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const Image& GetImage() const; int getLineSpacing(unsigned int characterSize) const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the SFML default built-in font (Arial) /// \brief Retrieve the texture containing the loaded glyphs of a certa
in size
///
/// The contents of the returned texture changes as more glyphs
/// are requested, thus it is not very relevant. It is mainly
/// used internally by sf::Text.
///
/// \param characterSize Reference character size
///
/// \return Texture containing the glyphs of the requested size
///
////////////////////////////////////////////////////////////
const Texture& getTexture(unsigned int characterSize) const;
////////////////////////////////////////////////////////////
/// \brief Overload of assignment operator
///
/// \param right Instance to assign
/// ///
/// \return Instance of the default font /// \return Reference to self
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static const Font& GetDefaultFont(); Font& operator =(const Font& right);
private : private :
friend class priv::FontLoader; ////////////////////////////////////////////////////////////
/// \brief Structure defining a row of glyphs
///
////////////////////////////////////////////////////////////
struct Row
{
Row(unsigned int rowTop, unsigned int rowHeight) : width(0), top(ro
wTop), height(rowHeight) {}
unsigned int width; ///< Current width of the row
unsigned int top; ///< Y position of the row into the texture
unsigned int height; ///< Height of the row
};
////////////////////////////////////////////////////////////
// Types
////////////////////////////////////////////////////////////
typedef std::map<Uint32, Glyph> GlyphTable; ///< Table mapping a codepo
int to its glyph
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Static member data /// \brief Structure defining a page of glyphs
///
////////////////////////////////////////////////////////////
struct Page
{
Page();
GlyphTable glyphs; ///< Table mapping code points to their c
orresponding glyph
sf::Texture texture; ///< Texture containing the pixels of the
glyphs
unsigned int nextRow; ///< Y position of the next new row in th
e texture
std::vector<Row> rows; ///< List containing the position of all
the existing rows
};
////////////////////////////////////////////////////////////
/// \brief Free all the internal resources
///
////////////////////////////////////////////////////////////
void cleanup();
////////////////////////////////////////////////////////////
/// \brief Load a new glyph and store it in the cache
///
/// \param codePoint Unicode code point of the character to load
/// \param characterSize Reference character size
/// \param bold Retrieve the bold version or the regular one?
///
/// \return The glyph corresponding to \a codePoint and \a characterSiz
e
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static Uint32 ourDefaultCharset[]; ///< The default charset (all printa Glyph loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold
ble ISO-8859-1 characters) ) const;
////////////////////////////////////////////////////////////
/// \brief Find a suitable rectangle within the texture for a glyph
///
/// \param page Page of glyphs to search in
/// \param width Width of the rectangle
/// \param height Height of the rectangle
///
/// \return Found rectangle within the texture
///
////////////////////////////////////////////////////////////
IntRect findGlyphRect(Page& page, unsigned int width, unsigned int heig
ht) const;
////////////////////////////////////////////////////////////
/// \brief Make sure that the given size is the current one
///
/// \param characterSize Reference character size
///
/// \return True on success, false if any error happened
///
////////////////////////////////////////////////////////////
bool setCurrentSize(unsigned int characterSize) const;
////////////////////////////////////////////////////////////
// Types
////////////////////////////////////////////////////////////
typedef std::map<unsigned int, Page> PageTable; ///< Table mapping a ch
aracter size to its page (texture)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Image myTexture; ///< Texture holding the bitmap fon void* m_library; ///< Pointer to the internal
t library interface (it is typeless to avoid exposing implementation details)
unsigned int myCharSize; ///< Size of characters in the bitm void* m_face; ///< Pointer to the internal
ap font font face (it is typeless to avoid exposing implementation details)
std::map<Uint32, Glyph> myGlyphs; ///< Rendering settings of each cha void* m_streamRec; ///< Pointer to the stream re
racter (glyph) c instance (it is typeless to avoid exposing implementation details)
int* m_refCount; ///< Reference counter used b
y implicit sharing
mutable PageTable m_pages; ///< Table containing the gly
phs pages by character size
mutable std::vector<Uint8> m_pixelBuffer; ///< Pixel buffer holding a g
lyph's pixels before being written to the texture
}; };
} // namespace sf } // namespace sf
#endif // SFML_FONT_HPP #endif // SFML_FONT_HPP
////////////////////////////////////////////////////////////
/// \class sf::Font
/// \ingroup graphics
///
/// Fonts can be loaded from a file, from memory or from a custom
/// stream, and supports the most common types of fonts. See
/// the loadFromFile function for the complete list of supported formats.
///
/// Once it is loaded, a sf::Font instance provides three
/// types of information about the font:
/// \li Global metrics, such as the line spacing
/// \li Per-glyph metrics, such as bounding box or kerning
/// \li Pixel representation of glyphs
///
/// Fonts alone are not very useful: they hold the font data
/// but cannot make anything useful of it. To do so you need to
/// use the sf::Text class, which is able to properly output text
/// with several options such as character size, style, color,
/// position, rotation, etc.
/// This separation allows more flexibility and better performances:
/// indeed a sf::Font is a heavy resource, and any operation on it
/// is slow (often too slow for real-time applications). On the other
/// side, a sf::Text is a lightweight object which can combine the
/// glyphs data and metrics of a sf::Font to display any text on a
/// render target.
/// Note that it is also possible to bind several sf::Text instances
/// to the same sf::Font.
///
/// It is important to note that the sf::Text instance doesn't
/// copy the font that it uses, it only keeps a reference to it.
/// Thus, a sf::Font must not be destructed while it is
/// used by a sf::Text (i.e. never write a function that
/// uses a local sf::Font instance for creating a text).
///
/// Usage example:
/// \code
/// // Declare a new font
/// sf::Font font;
///
/// // Load it from a file
/// if (!font.loadFromFile("arial.ttf"))
/// {
/// // error...
/// }
///
/// // Create a text which uses our font
/// sf::Text text1;
/// text1.setFont(font);
/// text1.setCharacterSize(30);
/// text1.setStyle(sf::Text::Regular);
///
/// // Create another text using the same font, but with different paramete
rs
/// sf::Text text2;
/// text2.setFont(font);
/// text2.setCharacterSize(50);
/// text1.setStyle(sf::Text::Italic);
/// \endcode
///
/// Apart from loading font files, and passing them to instances
/// of sf::Text, you should normally not have to deal directly
/// with this class. However, it may be useful to access the
/// font metrics or rasterized glyphs for advanced usage.
///
/// \see sf::Text
///
////////////////////////////////////////////////////////////
 End of changes. 36 change blocks. 
58 lines changed or deleted 214 lines changed or added


 Ftp.hpp   Ftp.hpp 
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// //
// SFML - Simple and Fast Multimedia Library // SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// //
// This software is provided 'as-is', without any express or implied warran ty. // This software is provided 'as-is', without any express or implied warran ty.
// In no event will the authors be held liable for any damages arising from the use of this software. // 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, // Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it f reely, // including commercial applications, and to alter it and redistribute it f reely,
// subject to the following restrictions: // subject to the following restrictions:
// //
// 1. The origin of this software must not be misrepresented; // 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software. // you must not claim that you wrote the original software.
skipping to change at line 31 skipping to change at line 31
// 3. This notice may not be removed or altered from any source distributio n. // 3. This notice may not be removed or altered from any source distributio n.
// //
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#ifndef SFML_FTP_HPP #ifndef SFML_FTP_HPP
#define SFML_FTP_HPP #define SFML_FTP_HPP
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Network/Export.hpp>
#include <SFML/Network/TcpSocket.hpp>
#include <SFML/System/NonCopyable.hpp> #include <SFML/System/NonCopyable.hpp>
#include <SFML/Network/SocketTCP.hpp> #include <SFML/System/Time.hpp>
#include <string> #include <string>
#include <vector> #include <vector>
namespace sf namespace sf
{ {
class IPAddress; class IpAddress;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// This class provides methods for manipulating the FTP /// \brief A FTP client
/// protocol (described in RFC 959). ///
/// It provides easy access and transfers to remote
/// directories and files on a FTP server
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class SFML_API Ftp : NonCopyable class SFML_NETWORK_API Ftp : NonCopyable
{ {
public : public :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Enumeration of transfer modes /// \brief Enumeration of transfer modes
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
enum TransferMode enum TransferMode
{ {
Binary, ///< Binary mode (file is transfered as a sequence of bytes ) Binary, ///< Binary mode (file is transfered as a sequence of bytes )
Ascii, ///< Text mode using ASCII encoding Ascii, ///< Text mode using ASCII encoding
Ebcdic ///< Text mode using EBCDIC encoding Ebcdic ///< Text mode using EBCDIC encoding
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// This class wraps a FTP response, which is basically : /// \brief Define a FTP response
/// - a status code ///
/// - a message
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class SFML_API Response class SFML_NETWORK_API Response
{ {
public : public :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Enumerate all the valid status codes returned in /// \brief Status codes possibly returned by a FTP response
/// a FTP response ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
enum Status enum Status
{ {
// 1xx: the requested action is being initiated, // 1xx: the requested action is being initiated,
// expect another reply before proceeding with a new command // expect another reply before proceeding with a new command
RestartMarkerReply = 110, ///< Restart marker reply RestartMarkerReply = 110, ///< Restart marker reply
ServiceReadySoon = 120, ///< Service ready in N minu tes ServiceReadySoon = 120, ///< Service ready in N minu tes
DataConnectionAlreadyOpened = 125, ///< Data connection already opened, transfer starting DataConnectionAlreadyOpened = 125, ///< Data connection already opened, transfer starting
OpeningDataConnection = 150, ///< File status ok, about t o open data connection OpeningDataConnection = 150, ///< File status ok, about t o open data connection
skipping to change at line 136 skipping to change at line 136
FilenameNotAllowed = 553, ///< Requested action not taken, file name not allowed FilenameNotAllowed = 553, ///< Requested action not taken, file name not allowed
// 10xx: SFML custom codes // 10xx: SFML custom codes
InvalidResponse = 1000, ///< Response is not a valid FTP one InvalidResponse = 1000, ///< Response is not a valid FTP one
ConnectionFailed = 1001, ///< Connection with server failed ConnectionFailed = 1001, ///< Connection with server failed
ConnectionClosed = 1002, ///< Connection with server closed ConnectionClosed = 1002, ///< Connection with server closed
InvalidFile = 1003 ///< Invalid file to upload / download InvalidFile = 1003 ///< Invalid file to upload / download
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Default constructor /// \brief Default constructor
/// ///
/// \param Code : Response status code (InvalidResponse by defau /// This constructor is used by the FTP client to build
lt) /// the response.
/// \param Message : Response message (empty by default) ///
/// \param code Response status code
/// \param message Response message
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Response(Status Code = InvalidResponse, const std::string& Message = ""); explicit Response(Status code = InvalidResponse, const std::string& message = "");
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Convenience function to check if the response status code /// \brief Check if the status code means a success
/// means a success ///
/// This function is defined for convenience, it is
/// equivalent to testing if the status code is < 400.
/// ///
/// \return True if status is success (code < 400) /// \return True if the status is a success, false if it is a failu re
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
bool IsOk() const; bool isOk() const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the response status code /// \brief Get the status code of the response
/// ///
/// \return Status code /// \return Status code
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Status GetStatus() const; Status getStatus() const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the full message contained in the response /// \brief Get the full message contained in the response
/// ///
/// \return The response message /// \return The response message
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const std::string& GetMessage() const; const std::string& getMessage() const;
private : private :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Status myStatus; ///< Status code returned from the server Status m_status; ///< Status code returned from the server
std::string myMessage; ///< Last message received from the server std::string m_message; ///< Last message received from the server
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Specialization of FTP response returning a directory /// \brief Specialization of FTP response returning a directory
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class SFML_API DirectoryResponse : public Response class SFML_NETWORK_API DirectoryResponse : public Response
{ {
public : public :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Default constructor /// \brief Default constructor
/// ///
/// \param Resp : Source response /// \param response Source response
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
DirectoryResponse(Response Resp); DirectoryResponse(const Response& response);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the directory returned in the response /// \brief Get the directory returned in the response
/// ///
/// \return Directory name /// \return Directory name
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const std::string& GetDirectory() const; const std::string& getDirectory() const;
private : private :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
std::string myDirectory; ///< Directory extracted from the response message std::string m_directory; ///< Directory extracted from the response message
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Specialization of FTP response returning a filename lisiting /// \brief Specialization of FTP response returning a
/// filename lisiting
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class SFML_API ListingResponse : public Response class SFML_NETWORK_API ListingResponse : public Response
{ {
public : public :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Default constructor /// \brief Default constructor
///
/// \param Resp : Source response
/// \param Data : Data containing the raw listing
///
////////////////////////////////////////////////////////////
ListingResponse(Response Resp, const std::vector<char>& Data);
////////////////////////////////////////////////////////////
/// Get the number of filenames in the listing
/// ///
/// \return Total number of filenames /// \param response Source response
/// \param data Data containing the raw listing
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
std::size_t GetCount() const; ListingResponse(const Response& response, const std::vector<char>& data);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the Index-th filename in the directory /// \brief Return the array of directory/file names
/// ///
/// \param Index : Index of the filename to get /// \return Array containing the requested listing
///
/// \return Index-th filename
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const std::string& GetFilename(std::size_t Index) const; const std::vector<std::string>& getListing() const;
private : private :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
std::vector<std::string> myFilenames; ///< Filenames extracted from the data std::vector<std::string> m_listing; ///< Directory/file names extra cted from the data
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destructor -- close the connection with the server /// \brief Destructor
///
/// Automatically closes the connection with the server if
/// it is still opened.
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
~Ftp(); ~Ftp();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Connect to the specified FTP server /// \brief Connect to the specified FTP server
///
/// The port has a default value of 21, which is the standard
/// port used by the FTP protocol. You shouldn't use a different
/// value, unless you really know what you do.
/// This function tries to connect to the server so it may take
/// a while to complete, especially if the server is not
/// reachable. To avoid blocking your application for too long,
/// you can use a timeout. The default value, Time::Zero, means that th
e
/// system timeout will be used (which is usually pretty long).
/// ///
/// \param Server : FTP server to connect to /// \param server Name or address of the FTP server to connect to
/// \param Port : Port used for connection (21 by default, standard /// \param port Port used for the connection
FTP port) /// \param timeout Maximum time to wait
/// \param Timeout : Maximum time to wait, in seconds (0 by default, me
ans no timeout)
/// ///
/// \return Server response to the request /// \return Server response to the request
/// ///
/// \see disconnect
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Response Connect(const IPAddress& Server, unsigned short Port = 21, flo at Timeout = 0.f); Response connect(const IpAddress& server, unsigned short port = 21, Tim e timeout = Time::Zero);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Log in using anonymous account /// \brief Close the connection with the server
/// ///
/// \return Server response to the request /// \return Server response to the request
/// ///
/// \see connect
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Response Login(); Response disconnect();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Log in using a username and a password /// \brief Log in using an anonymous account
/// ///
/// \param UserName : User name /// Logging in is mandatory after connecting to the server.
/// \param Password : Password /// Users that are not logged in cannot perform any operation.
/// ///
/// \return Server response to the request /// \return Server response to the request
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Response Login(const std::string& UserName, const std::string& Password ); Response login();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Close the connection with FTP server /// \brief Log in using a username and a password
///
/// Logging in is mandatory after connecting to the server.
/// Users that are not logged in cannot perform any operation.
///
/// \param name User name
/// \param password Password
/// ///
/// \return Server response to the request /// \return Server response to the request
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Response Disconnect(); Response login(const std::string& name, const std::string& password);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Send a null command just to prevent from being disconnected /// \brief Send a null command to keep the connection alive
///
/// This command is useful because the server may close the
/// connection automatically if no command is sent.
/// ///
/// \return Server response to the request /// \return Server response to the request
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Response KeepAlive(); Response keepAlive();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the current working directory /// \brief Get the current working directory
///
/// The working directory is the root path for subsequent
/// operations involving directories and/or filenames.
/// ///
/// \return Server response to the request /// \return Server response to the request
/// ///
/// \see getDirectoryListing, changeDirectory, parentDirectory
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
DirectoryResponse GetWorkingDirectory(); DirectoryResponse getWorkingDirectory();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the contents of the given directory /// \brief Get the contents of the given directory
/// (subdirectories and files) ///
/// This function retrieves the sub-directories and files
/// contained in the given directory. It is not recursive.
/// The \a directory parameter is relative to the current
/// working directory.
/// ///
/// \param Directory : Directory to list ("" by default, the current on e) /// \param directory Directory to list
/// ///
/// \return Server response to the request /// \return Server response to the request
/// ///
/// \see getWorkingDirectory, changeDirectory, parentDirectory
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
ListingResponse GetDirectoryListing(const std::string& Directory = ""); ListingResponse getDirectoryListing(const std::string& directory = "");
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Change the current working directory /// \brief Change the current working directory
///
/// The new directory must be relative to the current one.
/// ///
/// \param Directory : New directory, relative to the current one /// \param directory New working directory
/// ///
/// \return Server response to the request /// \return Server response to the request
/// ///
/// \see getWorkingDirectory, getDirectoryListing, parentDirectory
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Response ChangeDirectory(const std::string& Directory); Response changeDirectory(const std::string& directory);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Go to the parent directory of the current one /// \brief Go to the parent directory of the current one
/// ///
/// \return Server response to the request /// \return Server response to the request
/// ///
/// \see getWorkingDirectory, getDirectoryListing, changeDirectory
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Response ParentDirectory(); Response parentDirectory();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Create a new directory /// \brief Create a new directory
///
/// The new directory is created as a child of the current
/// working directory.
/// ///
/// \param Name : Name of the directory to create /// \param name Name of the directory to create
/// ///
/// \return Server response to the request /// \return Server response to the request
/// ///
/// \see deleteDirectory
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Response MakeDirectory(const std::string& Name); Response createDirectory(const std::string& name);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Remove an existing directory /// \brief Remove an existing directory
/// ///
/// \param Name : Name of the directory to remove /// The directory to remove must be relative to the
/// current working directory.
/// Use this function with caution, the directory will
/// be removed permanently!
///
/// \param name Name of the directory to remove
/// ///
/// \return Server response to the request /// \return Server response to the request
/// ///
/// \see createDirectory
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Response DeleteDirectory(const std::string& Name); Response deleteDirectory(const std::string& name);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Rename a file /// \brief Rename an existing file
///
/// The filenames must be relative to the current working
/// directory.
/// ///
/// \param File : File to rename /// \param file File to rename
/// \param NewName : New name /// \param newName New name of the file
/// ///
/// \return Server response to the request /// \return Server response to the request
/// ///
/// \see deleteFile
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Response RenameFile(const std::string& File, const std::string& NewName ); Response renameFile(const std::string& file, const std::string& newName );
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Remove an existing file /// \brief Remove an existing file
///
/// The file name must be relative to the current working
/// directory.
/// Use this function with caution, the file will be
/// removed permanently!
/// ///
/// \param Name : File to remove /// \param name File to remove
/// ///
/// \return Server response to the request /// \return Server response to the request
/// ///
/// \see renameFile
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Response DeleteFile(const std::string& Name); Response deleteFile(const std::string& name);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Download a file from the server /// \brief Download a file from the server
///
/// The filename of the distant file is relative to the
/// current working directory of the server, and the local
/// destination path is relative to the current directory
/// of your application.
/// ///
/// \param DistantFile : Path of the distant file to download /// \param remoteFile Filename of the distant file to download
/// \param DestPath : Where to put to file on the local computer /// \param localPath Where to put to file on the local computer
/// \param Mode : Transfer mode (binary by default) /// \param mode Transfer mode
/// ///
/// \return Server response to the request /// \return Server response to the request
/// ///
/// \see upload
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Response Download(const std::string& DistantFile, const std::string& De stPath, TransferMode Mode = Binary); Response download(const std::string& remoteFile, const std::string& loc alPath, TransferMode mode = Binary);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Upload a file to the server /// \brief Upload a file to the server
/// ///
/// \param LocalFile : Path of the local file to upload /// The name of the local file is relative to the current
/// \param DestPath : Where to put to file on the server /// working directory of your application, and the
/// \param Mode : Transfer mode (binary by default) /// remote path is relative to the current directory of the
/// FTP server.
///
/// \param localFile Path of the local file to upload
/// \param remotePath Where to put to file on the server
/// \param mode Transfer mode
/// ///
/// \return Server response to the request /// \return Server response to the request
/// ///
/// \see download
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Response Upload(const std::string& LocalFile, const std::string& DestPa th, TransferMode Mode = Binary); Response upload(const std::string& localFile, const std::string& remote Path, TransferMode mode = Binary);
private : private :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Send a command to the FTP server /// \brief Send a command to the FTP server
/// ///
/// \param Command : Command to send /// \param command Command to send
/// \param Parameter : Command parameter ("" by default) /// \param parameter Command parameter
/// ///
/// \return Server response to the request /// \return Server response to the request
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Response SendCommand(const std::string& Command, const std::string& Par ameter = ""); Response sendCommand(const std::string& command, const std::string& par ameter = "");
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Receive a response from the server /// \brief Receive a response from the server
/// (usually after a command has been sent) ///
/// This function must be called after each call to
/// SendCommand that expects a response.
/// ///
/// \return Server response to the request /// \return Server response to the request
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Response GetResponse(); Response getResponse();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Utility class for exchanging datas with the server /// \brief Utility class for exchanging datas with the server
/// on the data channel /// on the data channel
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class DataChannel; class DataChannel;
friend class DataChannel; friend class DataChannel;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
SocketTCP myCommandSocket; ///< Socket holding the control connection w ith the server TcpSocket m_commandSocket; ///< Socket holding the control connection w ith the server
}; };
} // namespace sf } // namespace sf
#endif // SFML_FTP_HPP #endif // SFML_FTP_HPP
////////////////////////////////////////////////////////////
/// \class sf::Ftp
/// \ingroup network
///
/// sf::Ftp is a very simple FTP client that allows you
/// to communicate with a FTP server. The FTP protocol allows
/// you to manipulate a remote file system (list files,
/// upload, download, create, remove, ...).
///
/// Using the FTP client consists of 4 parts:
/// \li Connecting to the FTP server
/// \li Logging in (either as a registered user or anonymously)
/// \li Sending commands to the server
/// \li Disconnecting (this part can be done implicitely by the destructor)
///
/// Every command returns a FTP response, which contains the
/// status code as well as a message from the server. Some
/// commands such as getWorkingDirectory and getDirectoryListing
/// return additional data, and use a class derived from
/// sf::Ftp::Response to provide this data.
///
/// All commands, especially upload and download, may take some
/// time to complete. This is important to know if you don't want
/// to block your application while the server is completing
/// the task.
///
/// Usage example:
/// \code
/// // Create a new FTP client
/// sf::Ftp ftp;
///
/// // Connect to the server
/// sf::Ftp::Response response = ftp.connect("ftp://ftp.myserver.com");
/// if (response.isOk())
/// std::cout << "Connected" << std::endl;
///
/// // Log in
/// response = ftp.login("laurent", "dF6Zm89D");
/// if (response.isOk())
/// std::cout << "Logged in" << std::endl;
///
/// // Print the working directory
/// sf::Ftp::DirectoryResponse directory = ftp.getWorkingDirectory();
/// if (directory.isOk())
/// std::cout << "Working directory: " << directory.getDirectory() << s
td::endl;
///
/// // Create a new directory
/// response = ftp.createDirectory("files");
/// if (response.isOk())
/// std::cout << "Created new directory" << std::endl;
///
/// // Upload a file to this new directory
/// response = ftp.upload("local-path/file.txt", "files", sf::Ftp::Ascii);
/// if (response.isOk())
/// std::cout << "File uploaded" << std::endl;
///
/// // Disconnect from the server (optional)
/// ftp.disconnect();
/// \endcode
///
////////////////////////////////////////////////////////////
 End of changes. 99 change blocks. 
120 lines changed or deleted 198 lines changed or added


 Glyph.hpp   Glyph.hpp 
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// //
// SFML - Simple and Fast Multimedia Library // SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// //
// This software is provided 'as-is', without any express or implied warran ty. // This software is provided 'as-is', without any express or implied warran ty.
// In no event will the authors be held liable for any damages arising from the use of this software. // 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, // Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it f reely, // including commercial applications, and to alter it and redistribute it f reely,
// subject to the following restrictions: // subject to the following restrictions:
// //
// 1. The origin of this software must not be misrepresented; // 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software. // you must not claim that you wrote the original software.
skipping to change at line 31 skipping to change at line 31
// 3. This notice may not be removed or altered from any source distributio n. // 3. This notice may not be removed or altered from any source distributio n.
// //
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#ifndef SFML_GLYPH_HPP #ifndef SFML_GLYPH_HPP
#define SFML_GLYPH_HPP #define SFML_GLYPH_HPP
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Config.hpp> #include <SFML/Graphics/Export.hpp>
#include <SFML/Graphics/Rect.hpp> #include <SFML/Graphics/Rect.hpp>
namespace sf namespace sf
{ {
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Structure describing a glyph (a visual character) /// \brief Structure describing a glyph
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class SFML_API Glyph class SFML_GRAPHICS_API Glyph
{ {
public : public :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Default constructor /// \brief Default constructor
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Glyph() : Advance(0) {} Glyph() : advance(0) {}
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
int Advance; ///< Offset to move horizontically to the next cha int advance; ///< Offset to move horizontically to the next cha
racter racter
IntRect Rectangle; ///< Bounding rectangle of the glyph, in relative IntRect bounds; ///< Bounding rectangle of the glyph, in coordinat
coordinates es relative to the baseline
FloatRect TexCoords; ///< Texture coordinates of the glyph inside the b IntRect textureRect; ///< Texture coordinates of the glyph inside the f
itmap font ont's texture
}; };
} // namespace sf } // namespace sf
#endif // SFML_GLYPH_HPP #endif // SFML_GLYPH_HPP
////////////////////////////////////////////////////////////
/// \class sf::Glyph
/// \ingroup graphics
///
/// A glyph is the visual representation of a character.
///
/// The sf::Glyph structure provides the information needed
/// to handle the glyph:
/// \li its coordinates in the font's texture
/// \li its bounding rectangle
/// \li the offset to apply to get the starting position of the next glyph
///
/// \see sf::Font
///
////////////////////////////////////////////////////////////
 End of changes. 8 change blocks. 
12 lines changed or deleted 13 lines changed or added


 Graphics.hpp   Graphics.hpp 
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// //
// SFML - Simple and Fast Multimedia Library // SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// //
// This software is provided 'as-is', without any express or implied warran ty. // This software is provided 'as-is', without any express or implied warran ty.
// In no event will the authors be held liable for any damages arising from the use of this software. // 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, // Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it f reely, // including commercial applications, and to alter it and redistribute it f reely,
// subject to the following restrictions: // subject to the following restrictions:
// //
// 1. The origin of this software must not be misrepresented; // 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software. // you must not claim that you wrote the original software.
skipping to change at line 33 skipping to change at line 33
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#ifndef SFML_GRAPHICS_HPP #ifndef SFML_GRAPHICS_HPP
#define SFML_GRAPHICS_HPP #define SFML_GRAPHICS_HPP
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Window.hpp> #include <SFML/Window.hpp>
#include <SFML/Graphics/BlendMode.hpp>
#include <SFML/Graphics/Color.hpp> #include <SFML/Graphics/Color.hpp>
#include <SFML/Graphics/Font.hpp> #include <SFML/Graphics/Font.hpp>
#include <SFML/Graphics/Glyph.hpp> #include <SFML/Graphics/Glyph.hpp>
#include <SFML/Graphics/Image.hpp> #include <SFML/Graphics/Image.hpp>
#include <SFML/Graphics/PostFX.hpp> #include <SFML/Graphics/RenderStates.hpp>
#include <SFML/Graphics/RenderTexture.hpp>
#include <SFML/Graphics/RenderWindow.hpp> #include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/Shader.hpp>
#include <SFML/Graphics/Shape.hpp> #include <SFML/Graphics/Shape.hpp>
#include <SFML/Graphics/CircleShape.hpp>
#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/Graphics/ConvexShape.hpp>
#include <SFML/Graphics/Sprite.hpp> #include <SFML/Graphics/Sprite.hpp>
#include <SFML/Graphics/String.hpp> #include <SFML/Graphics/Text.hpp>
#include <SFML/Graphics/Texture.hpp>
#include <SFML/Graphics/Transform.hpp>
#include <SFML/Graphics/Vertex.hpp>
#include <SFML/Graphics/VertexArray.hpp>
#include <SFML/Graphics/View.hpp> #include <SFML/Graphics/View.hpp>
#endif // SFML_GRAPHICS_HPP #endif // SFML_GRAPHICS_HPP
////////////////////////////////////////////////////////////
/// \defgroup graphics Graphics module
///
/// 2D graphics module: sprites, text, shapes, ...
///
////////////////////////////////////////////////////////////
 End of changes. 7 change blocks. 
3 lines changed or deleted 13 lines changed or added


 Http.hpp   Http.hpp 
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// //
// SFML - Simple and Fast Multimedia Library // SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// //
// This software is provided 'as-is', without any express or implied warran ty. // This software is provided 'as-is', without any express or implied warran ty.
// In no event will the authors be held liable for any damages arising from the use of this software. // 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, // Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it f reely, // including commercial applications, and to alter it and redistribute it f reely,
// subject to the following restrictions: // subject to the following restrictions:
// //
// 1. The origin of this software must not be misrepresented; // 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software. // you must not claim that you wrote the original software.
skipping to change at line 31 skipping to change at line 31
// 3. This notice may not be removed or altered from any source distributio n. // 3. This notice may not be removed or altered from any source distributio n.
// //
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#ifndef SFML_HTTP_HPP #ifndef SFML_HTTP_HPP
#define SFML_HTTP_HPP #define SFML_HTTP_HPP
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Network/Export.hpp>
#include <SFML/Network/IpAddress.hpp>
#include <SFML/Network/TcpSocket.hpp>
#include <SFML/System/NonCopyable.hpp> #include <SFML/System/NonCopyable.hpp>
#include <SFML/Network/IPAddress.hpp> #include <SFML/System/Time.hpp>
#include <SFML/Network/SocketTCP.hpp>
#include <map> #include <map>
#include <string> #include <string>
namespace sf namespace sf
{ {
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// This class provides methods for manipulating the HTTP /// \brief A HTTP client
/// protocol (described in RFC 1945). ///
/// It can connect to a website, get its files, send requests, etc.
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class SFML_API Http : NonCopyable class SFML_NETWORK_API Http : NonCopyable
{ {
public : public :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// This class wraps an HTTP request, which is basically : /// \brief Define a HTTP request
/// - a header with a method, a target URI, and a set of field/value pa ///
irs
/// - an optional body (for POST requests)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class SFML_API Request class SFML_NETWORK_API Request
{ {
public : public :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Enumerate the available HTTP methods for a request /// \brief Enumerate the available HTTP methods for a request
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
enum Method enum Method
{ {
Get, ///< Request in get mode, standard method to retrieve a p age Get, ///< Request in get mode, standard method to retrieve a p age
Post, ///< Request in post mode, usually to send data to a page Post, ///< Request in post mode, usually to send data to a page
Head ///< Request a page's header only Head ///< Request a page's header only
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Default constructor /// \brief Default constructor
/// ///
/// \param RequestMethod : Method to use for the request (Get by de /// This constructor creates a GET request, with the root
fault) /// URI ("/") and an empty body.
/// \param URI : Target URI ("/" by default -- index page ///
) /// \param uri Target URI
/// \param Body : Content of the request's body (empty by /// \param method Method to use for the request
default) /// \param body Content of the request's body
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Request(Method RequestMethod = Get, const std::string& URI = "/", c onst std::string& Body = ""); Request(const std::string& uri = "/", Method method = Get, const st d::string& body = "");
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Set the value of a field; the field is added if it doesn't exis /// \brief Set the value of a field
t ///
/// The field is created if it doesn't exist. The name of
/// the field is case insensitive.
/// By default, a request doesn't contain any field (but the
/// mandatory fields are added later by the HTTP client when
/// sending the request).
/// ///
/// \param Field : Name of the field to set (case-insensitive) /// \param field Name of the field to set
/// \param Value : Value of the field /// \param value Value of the field
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void SetField(const std::string& Field, const std::string& Value); void setField(const std::string& field, const std::string& value);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Set the request method. /// \brief Set the request method
/// This parameter is Http::Request::Get by default
/// ///
/// \param RequestMethod : Method to use for the request /// See the Method enumeration for a complete list of all
/// the availale methods.
/// The method is Http::Request::Get by default.
///
/// \param method Method to use for the request
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void SetMethod(Method RequestMethod); void setMethod(Method method);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Set the target URI of the request. /// \brief Set the requested URI
/// This parameter is "/" by default ///
/// The URI is the resource (usually a web page or a file)
/// that you want to get or post.
/// The URI is "/" (the root page) by default.
/// ///
/// \param URI : URI to request, local to the host /// \param uri URI to request, relative to the host
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void SetURI(const std::string& URI); void setUri(const std::string& uri);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Set the HTTP version of the request. /// \brief Set the HTTP version for the request
/// This parameter is 1.0 by default ///
/// The HTTP version is 1.0 by default.
/// ///
/// \param Major : Major version number /// \param major Major HTTP version number
/// \param Minor : Minor version number /// \param minor Minor HTTP version number
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void SetHttpVersion(unsigned int Major, unsigned int Minor); void setHttpVersion(unsigned int major, unsigned int minor);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Set the body of the request. This parameter is optional and /// \brief Set the body of the request
/// makes sense only for POST requests.
/// This parameter is empty by default
/// ///
/// \param Body : Content of the request body /// The body of a request is optional and only makes sense
/// for POST requests. It is ignored for all other methods.
/// The body is empty by default.
///
/// \param body Content of the body
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void SetBody(const std::string& Body); void setBody(const std::string& body);
private : private :
friend class Http; friend class Http;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the string representation of the request header /// \brief Prepare the final request to send to the server
///
/// This is used internally by Http before sending the
/// request to the web server.
/// ///
/// \return String containing the request /// \return String containing the request, ready to be sent
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
std::string ToString() const; std::string prepare() const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Check if the given field has been defined /// \brief Check if the request defines a field
///
/// This function uses case-insensitive comparisons.
/// ///
/// \param Field : Name of the field to check (case-insensitive) /// \param field Name of the field to test
/// ///
/// \return True if the field exists /// \return True if the field exists, false otherwise
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
bool HasField(const std::string& Field) const; bool hasField(const std::string& field) const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Types // Types
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
typedef std::map<std::string, std::string> FieldTable; typedef std::map<std::string, std::string> FieldTable;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
FieldTable myFields; ///< Fields of the header FieldTable m_fields; ///< Fields of the header associated t
Method myMethod; ///< Method to use for the request o their value
std::string myURI; ///< Target URI of the request Method m_method; ///< Method to use for the request
unsigned int myMajorVersion; ///< Major HTTP version std::string m_uri; ///< Target URI of the request
unsigned int myMinorVersion; ///< Minor HTTP version unsigned int m_majorVersion; ///< Major HTTP version
std::string myBody; ///< Body of the request unsigned int m_minorVersion; ///< Minor HTTP version
std::string m_body; ///< Body of the request
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// This class wraps an HTTP response, which is basically : /// \brief Define a HTTP response
/// - a header with a status code and a set of field/value pairs ///
/// - a body (the content of the requested resource)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class SFML_API Response class SFML_NETWORK_API Response
{ {
public : public :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Enumerate all the valid status codes returned in /// \brief Enumerate all the valid status codes for a response
/// a HTTP response ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
enum Status enum Status
{ {
// 2xx: success // 2xx: success
Ok = 200, ///< Most common code returned when operation Ok = 200, ///< Most common code returned when opera
was successful tion was successful
Created = 201, ///< The resource has successfully been create Created = 201, ///< The resource has successfully been c
d reated
Accepted = 202, ///< The request has been accepted, but will b Accepted = 202, ///< The request has been accepted, but w
e processed later by the server ill be processed later by the server
NoContent = 204, ///< Sent when the server didn't send any data NoContent = 204, ///< The server didn't send any data in r
in return eturn
ResetContent = 205, ///< The server informs the client that i
t should clear the view (form) that caused the request to be sent
PartialContent = 206, ///< The server has sent a part of the re
source, as a response to a partial GET request
// 3xx: redirection // 3xx: redirection
MultipleChoices = 300, ///< The requested page can be accessed from several locations MultipleChoices = 300, ///< The requested page can be accessed from several locations
MovedPermanently = 301, ///< The requested page has permanently moved to a new location MovedPermanently = 301, ///< The requested page has permanently moved to a new location
MovedTemporarily = 302, ///< The requested page has temporarily moved to a new location MovedTemporarily = 302, ///< The requested page has temporarily moved to a new location
NotModified = 304, ///< For conditionnal requests, means t he requested page hasn't changed and doesn't need to be refreshed NotModified = 304, ///< For conditionnal requests, means t he requested page hasn't changed and doesn't need to be refreshed
// 4xx: client error // 4xx: client error
BadRequest = 400, ///< The server couldn't understand the req BadRequest = 400, ///< The server couldn't understand
uest (syntax error) the request (syntax error)
Unauthorized = 401, ///< The requested page needs an authentifi Unauthorized = 401, ///< The requested page needs an aut
cation to be accessed hentification to be accessed
Forbidden = 403, ///< The requested page cannot be accessed Forbidden = 403, ///< The requested page cannot be ac
at all, even with authentification cessed at all, even with authentification
NotFound = 404, ///< The requested page doesn't exist NotFound = 404, ///< The requested page doesn't exis
t
RangeNotSatisfiable = 407, ///< The server can't satisfy the pa
rtial GET request (with a "Range" header field)
// 5xx: server error // 5xx: server error
InternalServerError = 500, ///< The server encountered an unexp ected error InternalServerError = 500, ///< The server encountered an unexp ected error
NotImplemented = 501, ///< The server doesn't implement a requested feature NotImplemented = 501, ///< The server doesn't implement a requested feature
BadGateway = 502, ///< The gateway server has received an error from the source server BadGateway = 502, ///< The gateway server has received an error from the source server
ServiceNotAvailable = 503, ///< The server is temporarily unava ilable (overloaded, in maintenance, ...) ServiceNotAvailable = 503, ///< The server is temporarily unava ilable (overloaded, in maintenance, ...)
GatewayTimeout = 504, ///< The gateway server couldn't rec
eive a response from the source server
VersionNotSupported = 505, ///< The server doesn't support the
requested HTTP version
// 10xx: SFML custom codes // 10xx: SFML custom codes
InvalidResponse = 1000, ///< Response is not a valid HTTP one InvalidResponse = 1000, ///< Response is not a valid HTTP one
ConnectionFailed = 1001 ///< Connection with server failed ConnectionFailed = 1001 ///< Connection with server failed
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Default constructor /// \brief Default constructor
///
/// Constructs an empty response.
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Response(); Response();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the value of a field /// \brief Get the value of a field
/// ///
/// \param Field : Name of the field to get (case-insensitive) /// If the field \a field is not found in the response header,
/// the empty string is returned. This function uses
/// case-insensitive comparisons.
///
/// \param field Name of the field to get
/// ///
/// \return Value of the field, or empty string if not found /// \return Value of the field, or empty string if not found
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const std::string& GetField(const std::string& Field) const; const std::string& getField(const std::string& field) const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the header's status code /// \brief Get the response status code
///
/// The status code should be the first thing to be checked
/// after receiving a response, it defines whether it is a
/// success, a failure or anything else (see the Status
/// enumeration).
/// ///
/// \return Header's status code /// \return Status code of the response
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Status GetStatus() const; Status getStatus() const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the major HTTP version number of the response /// \brief Get the major HTTP version number of the response
///
/// \return Major HTTP version number
/// ///
/// \return Major version number /// \see getMinorHttpVersion
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
unsigned int GetMajorHttpVersion() const; unsigned int getMajorHttpVersion() const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the major HTTP version number of the response /// \brief Get the minor HTTP version number of the response
/// ///
/// \return Major version number /// \return Minor HTTP version number
///
/// \see getMajorHttpVersion
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
unsigned int GetMinorHttpVersion() const; unsigned int getMinorHttpVersion() const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the body of the response. The body can contain : /// \brief Get the body of the response
/// - the requested page (for GET requests) ///
/// - a response from the server (for POST requests) /// The body of a response may contain:
/// - nothing (for HEAD requests) /// \li the requested page (for GET requests)
/// - an error message (in case of an error) /// \li a response from the server (for POST requests)
/// \li nothing (for HEAD requests)
/// \li an error message (in case of an error)
/// ///
/// \return The response body /// \return The response body
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const std::string& GetBody() const; const std::string& getBody() const;
private : private :
friend class Http; friend class Http;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Construct the header from a response string /// \brief Construct the header from a response string
///
/// This function is used by Http to build the response
/// of a request.
/// ///
/// \param Data : Content of the response's header to parse /// \param data Content of the response to parse
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void FromString(const std::string& Data); void parse(const std::string& data);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Types // Types
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
typedef std::map<std::string, std::string> FieldTable; typedef std::map<std::string, std::string> FieldTable;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
FieldTable myFields; ///< Fields of the header FieldTable m_fields; ///< Fields of the header
Status myStatus; ///< Status code Status m_status; ///< Status code
unsigned int myMajorVersion; ///< Major HTTP version unsigned int m_majorVersion; ///< Major HTTP version
unsigned int myMinorVersion; ///< Minor HTTP version unsigned int m_minorVersion; ///< Minor HTTP version
std::string myBody; ///< Body of the response std::string m_body; ///< Body of the response
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Default constructor /// \brief Default constructor
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Http(); Http();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Construct the Http instance with the target host /// \brief Construct the HTTP client with the target host
/// ///
/// \param Host : Web server to connect to /// This is equivalent to calling setHost(host, port).
/// \param Port : Port to use for connection (0 by default -- use the s /// The port has a default value of 0, which means that the
tandard port of the protocol used) /// HTTP client will use the right port according to the
/// protocol used (80 for HTTP, 443 for HTTPS). You should
/// leave it like this unless you really need a port other
/// than the standard one, or use an unknown protocol.
///
/// \param host Web server to connect to
/// \param port Port to use for connection
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Http(const std::string& Host, unsigned short Port = 0); Http(const std::string& host, unsigned short port = 0);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Set the target host /// \brief Set the target host
///
/// This function just stores the host address and port, it
/// doesn't actually connect to it until you send a request.
/// The port has a default value of 0, which means that the
/// HTTP client will use the right port according to the
/// protocol used (80 for HTTP, 443 for HTTPS). You should
/// leave it like this unless you really need a port other
/// than the standard one, or use an unknown protocol.
/// ///
/// \param Host : Web server to connect to /// \param host Web server to connect to
/// \param Port : Port to use for connection (0 by default -- use the s /// \param port Port to use for connection
tandard port of the protocol used)
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void SetHost(const std::string& Host, unsigned short Port = 0); void setHost(const std::string& host, unsigned short port = 0);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Send a HTTP request and return the server's response. /// \brief Send a HTTP request and return the server's response.
/// You must be connected to a host before sending requests. ///
/// Any missing mandatory header field will be added with an appropriat /// You must have a valid host before sending a request (see setHost).
e value. /// Any missing mandatory header field in the request will be added
/// Warning : this function waits for the server's response and may /// with an appropriate value.
/// Warning: this function waits for the server's response and may
/// not return instantly; use a thread if you don't want to block your /// not return instantly; use a thread if you don't want to block your
/// application. /// application, or use a timeout to limit the time to wait. A value
/// of Time::Zero means that the client will use the system defaut time
out
/// (which is usually pretty long).
/// ///
/// \param Req : Request to send /// \param request Request to send
/// \param Timeout : Maximum time to wait, in seconds (0 by default, me /// \param timeout Maximum time to wait
ans no timeout)
/// ///
/// \return Server's response /// \return Server's response
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Response SendRequest(const Request& Req, float Timeout = 0.f); Response sendRequest(const Request& request, Time timeout = Time::Zero) ;
private : private :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
SocketTCP myConnection; ///< Connection to the host TcpSocket m_connection; ///< Connection to the host
IPAddress myHost; ///< Web host address IpAddress m_host; ///< Web host address
std::string myHostName; ///< Web host name std::string m_hostName; ///< Web host name
unsigned short myPort; ///< Port used for connection with host unsigned short m_port; ///< Port used for connection with host
}; };
} // namespace sf } // namespace sf
#endif // SFML_HTTP_HPP #endif // SFML_HTTP_HPP
////////////////////////////////////////////////////////////
/// \class sf::Http
/// \ingroup network
///
/// sf::Http is a very simple HTTP client that allows you
/// to communicate with a web server. You can retrieve
/// web pages, send data to an interactive resource,
/// download a remote file, etc.
///
/// The HTTP client is split into 3 classes:
/// \li sf::Http::Request
/// \li sf::Http::Response
/// \li sf::Http
///
/// sf::Http::Request builds the request that will be
/// sent to the server. A request is made of:
/// \li a method (what you want to do)
/// \li a target URI (usually the name of the web page or file)
/// \li one or more header fields (options that you can pass to the server)
/// \li an optional body (for POST requests)
///
/// sf::Http::Response parse the response from the web server
/// and provides getters to read them. The response contains:
/// \li a status code
/// \li header fields (that may be answers to the ones that you requested)
/// \li a body, which contains the contents of the requested resource
///
/// sf::Http provides a simple function, SendRequest, to send a
/// sf::Http::Request and return the corresponding sf::Http::Response
/// from the server.
///
/// Usage example:
/// \code
/// // Create a new HTTP client
/// sf::Http http;
///
/// // We'll work on http://www.sfml-dev.org
/// http.setHost("http://www.sfml-dev.org");
///
/// // Prepare a request to get the 'features.php' page
/// sf::Http::Request request("features.php");
///
/// // Send the request
/// sf::Http::Response response = http.sendRequest(request);
///
/// // Check the status code and display the result
/// sf::Http::Response::Status status = response.getStatus();
/// if (status == sf::Http::Response::Ok)
/// {
/// std::cout << response.getBody() << std::endl;
/// }
/// else
/// {
/// std::cout << "Error " << status << std::endl;
/// }
/// \endcode
///
////////////////////////////////////////////////////////////
 End of changes. 72 change blocks. 
130 lines changed or deleted 196 lines changed or added


 Image.hpp   Image.hpp 
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// //
// SFML - Simple and Fast Multimedia Library // SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// //
// This software is provided 'as-is', without any express or implied warran ty. // This software is provided 'as-is', without any express or implied warran ty.
// In no event will the authors be held liable for any damages arising from the use of this software. // 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, // Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it f reely, // including commercial applications, and to alter it and redistribute it f reely,
// subject to the following restrictions: // subject to the following restrictions:
// //
// 1. The origin of this software must not be misrepresented; // 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software. // you must not claim that you wrote the original software.
skipping to change at line 31 skipping to change at line 31
// 3. This notice may not be removed or altered from any source distributio n. // 3. This notice may not be removed or altered from any source distributio n.
// //
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#ifndef SFML_IMAGE_HPP #ifndef SFML_IMAGE_HPP
#define SFML_IMAGE_HPP #define SFML_IMAGE_HPP
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/System/Resource.hpp> #include <SFML/Graphics/Export.hpp>
#include <SFML/Graphics/Color.hpp> #include <SFML/Graphics/Color.hpp>
#include <SFML/Graphics/Rect.hpp> #include <SFML/Graphics/Rect.hpp>
#include <string> #include <string>
#include <vector> #include <vector>
namespace sf namespace sf
{ {
class RenderWindow; class InputStream;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Image is the low-level class for loading and /// \brief Class for loading, manipulating and saving images
/// manipulating images ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class SFML_API Image : public Resource<Image> class SFML_GRAPHICS_API Image
{ {
public : public :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Default constructor /// \brief Default constructor
///
/// Creates an empty image.
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Image(); Image();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Copy constructor /// \brief Create the image and fill it with a unique color
/// ///
/// \param Copy : instance to copy /// \param width Width of the image
/// \param height Height of the image
/// \param color Fill color
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Image(const Image& Copy); void create(unsigned int width, unsigned int height, const Color& color = Color(0, 0, 0));
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Construct an empty image /// \brief Create the image from an array of pixels
///
/// \param Width : Image width
/// \param Height : Image height
/// \param Col : Image color (black by default)
/// ///
//////////////////////////////////////////////////////////// /// The \a pixel array is assumed to contain 32-bits RGBA pixels,
Image(unsigned int Width, unsigned int Height, const Color& Col = Color /// and have the given \a width and \a height. If not, this is
(0, 0, 0, 255)); /// an undefined behaviour.
/// If \a pixels is null, an empty image is created.
////////////////////////////////////////////////////////////
/// Construct the image from pixels in memory
/// ///
/// \param Width : Image width /// \param width Width of the image
/// \param Height : Image height /// \param height Height of the image
/// \param Data : Pointer to the pixels in memory (assumed format is /// \param pixels Array of pixels to copy to the image
RGBA)
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Image(unsigned int Width, unsigned int Height, const Uint8* Data); void create(unsigned int width, unsigned int height, const Uint8* pixel s);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destructor /// \brief Load the image from a file on disk
/// ///
//////////////////////////////////////////////////////////// /// The supported image formats are bmp, png, tga, jpg, gif,
~Image(); /// psd, hdr and pic. Some format options are not supported,
/// like progressive jpeg.
//////////////////////////////////////////////////////////// /// If this function fails, the image is left unchanged.
/// Load the image from a file
/// ///
/// \param Filename : Path of the image file to load /// \param filename Path of the image file to load
/// ///
/// \return True if loading was successful /// \return True if loading was successful
/// ///
//////////////////////////////////////////////////////////// /// \see loadFromMemory, loadFromStream, saveToFile
bool LoadFromFile(const std::string& Filename);
////////////////////////////////////////////////////////////
/// Load the image from a file in memory
///
/// \param Data : Pointer to the file data in memory
/// \param SizeInBytes : Size of the data to load, in bytes
///
/// \return True if loading was successful
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
bool LoadFromMemory(const char* Data, std::size_t SizeInBytes); bool loadFromFile(const std::string& filename);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Load the image directly from an array of pixels /// \brief Load the image from a file in memory
/// ///
/// \param Width : Image width /// The supported image formats are bmp, png, tga, jpg, gif,
/// \param Height : Image height /// psd, hdr and pic. Some format options are not supported,
/// \param Data : Pointer to the pixels in memory (assumed format is /// like progressive jpeg.
RGBA) /// If this function fails, the image is left unchanged.
///
/// \return True if loading was successful
/// ///
//////////////////////////////////////////////////////////// /// \param data Pointer to the file data in memory
bool LoadFromPixels(unsigned int Width, unsigned int Height, const Uint /// \param size Size of the data to load, in bytes
8* Data);
////////////////////////////////////////////////////////////
/// Save the content of the image to a file
/// ///
/// \param Filename : Path of the file to save (overwritten if already exist) /// \return True if loading was successful
/// ///
/// \return True if saving was successful /// \see loadFromFile, loadFromStream
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
bool SaveToFile(const std::string& Filename) const; bool loadFromMemory(const void* data, std::size_t size);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Create an empty image /// \brief Load the image from a custom stream
///
/// \param Width : Image width
/// \param Height : Image height
/// \param Col : Image color (black by default)
/// ///
/// \return True if creation was successful /// The supported image formats are bmp, png, tga, jpg, gif,
/// /// psd, hdr and pic. Some format options are not supported,
//////////////////////////////////////////////////////////// /// like progressive jpeg.
bool Create(unsigned int Width, unsigned int Height, Color Col = Color( /// If this function fails, the image is left unchanged.
0, 0, 0, 255));
////////////////////////////////////////////////////////////
/// Create transparency mask from a specified colorkey
/// ///
/// \param ColorKey : Color to become transparent /// \param stream Source stream to read from
/// \param Alpha : Alpha value to use for transparent pixels (0 by d
efault)
/// ///
//////////////////////////////////////////////////////////// /// \return True if loading was successful
void CreateMaskFromColor(Color ColorKey, Uint8 Alpha = 0);
////////////////////////////////////////////////////////////
/// Copy pixels from another image onto this one.
/// This function does a slow pixel copy and should only
/// be used at initialization time
/// ///
/// \param Source : Source image to copy /// \see loadFromFile, loadFromMemory
/// \param DestX : X coordinate of the destination position
/// \param DestY : Y coordinate of the destination position
/// \param SourceRect : Sub-rectangle of the source image to copy (empt
y by default - entire image)
/// \param ApplyAlpha : Should the copy take in account the source tran
sparency? (false by default)
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Copy(const Image& Source, unsigned int DestX, unsigned int DestY, const IntRect& SourceRect = IntRect(0, 0, 0, 0), bool ApplyAlpha = false); bool loadFromStream(InputStream& stream);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Create the image from the current contents of the /// \brief Save the image to a file on disk
/// given window
/// ///
/// \param Window : Window to capture /// The format of the image is automatically deduced from
/// \param SourceRect : Sub-rectangle of the screen to copy (empty by d /// the extension. The supported image formats are bmp, png,
efault - entire image) /// tga and jpg. The destination file is overwritten
/// if it already exists. This function fails if the image is empty.
/// ///
/// \return True if copy was successful /// \param filename Path of the file to save
/// ///
//////////////////////////////////////////////////////////// /// \return True if saving was successful
bool CopyScreen(RenderWindow& Window, const IntRect& SourceRect = IntRe
ct(0, 0, 0, 0));
////////////////////////////////////////////////////////////
/// Change the color of a pixel
/// ///
/// \param X : X coordinate of pixel in the image /// \see create, loadFromFile, loadFromMemory
/// \param Y : Y coordinate of pixel in the image
/// \param Col : New color for pixel (X, Y)
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void SetPixel(unsigned int X, unsigned int Y, const Color& Col); bool saveToFile(const std::string& filename) const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get a pixel from the image /// \brief Return the size (width and height) of the image
/// ///
/// \param X : X coordinate of pixel in the image /// \return Size of the image, in pixels
/// \param Y : Y coordinate of pixel in the image
///
/// \return Color of pixel (X, Y)
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const Color& GetPixel(unsigned int X, unsigned int Y) const; Vector2u getSize() const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get a read-only pointer to the array of pixels (RGBA 8 bits integer /// \brief Create a transparency mask from a specified color-key
s components)
/// Array size is GetWidth() x GetHeight() x 4
/// This pointer becomes invalid if you reload or resize the image
/// ///
/// \return Const pointer to the array of pixels /// This function sets the alpha value of every pixel matching
/// the given color to \a alpha (0 by default), so that they
/// become transparent.
/// ///
//////////////////////////////////////////////////////////// /// \param color Color to make transparent
const Uint8* GetPixelsPtr() const; /// \param alpha Alpha value to assign to transparent pixels
////////////////////////////////////////////////////////////
/// Bind the image for rendering
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Bind() const; void createMaskFromColor(const Color& color, Uint8 alpha = 0);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Enable or disable image smooth filter. /// \brief Copy pixels from another image onto this one
/// This parameter is enabled by default
/// ///
/// \param Smooth : True to enable smoothing filter, false to disable i /// This function does a slow pixel copy and should not be
t /// used intensively. It can be used to prepare a complex
/// static image from several others, but if you need this
/// kind of feature in real-time you'd better use sf::RenderTexture.
/// ///
//////////////////////////////////////////////////////////// /// If \a sourceRect is empty, the whole image is copied.
void SetSmooth(bool Smooth); /// If \a applyAlpha is set to true, the transparency of
/// source pixels is applied. If it is false, the pixels are
//////////////////////////////////////////////////////////// /// copied unchanged with their alpha value.
/// Return the width of the image
/// ///
/// \return Width in pixels /// \param source Source image to copy
/// \param destX X coordinate of the destination position
/// \param destY Y coordinate of the destination position
/// \param sourceRect Sub-rectangle of the source image to copy
/// \param applyAlpha Should the copy take in account the source transp
arency?
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
unsigned int GetWidth() const; void copy(const Image& source, unsigned int destX, unsigned int destY, const IntRect& sourceRect = IntRect(0, 0, 0, 0), bool applyAlpha = false);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Return the height of the image /// \brief Change the color of a pixel
/// ///
/// \return Height in pixels /// This function doesn't check the validity of the pixel
/// coordinates, using out-of-range values will result in
/// an undefined behaviour.
/// ///
//////////////////////////////////////////////////////////// /// \param x X coordinate of pixel to change
unsigned int GetHeight() const; /// \param y Y coordinate of pixel to change
/// \param color New color of the pixel
////////////////////////////////////////////////////////////
/// Tells whether the smooth filtering is enabled or not
/// ///
/// \return True if image smoothing is enabled /// \see getPixel
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
bool IsSmooth() const; void setPixel(unsigned int x, unsigned int y, const Color& color);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Convert a subrect expressed in pixels, into float /// \brief Get the color of a pixel
/// texture coordinates
/// ///
/// \param Rect : Sub-rectangle of image to convert /// This function doesn't check the validity of the pixel
/// coordinates, using out-of-range values will result in
/// an undefined behaviour.
/// ///
/// \return Texture coordinates corresponding to the sub-rectangle /// \param x X coordinate of pixel to get
/// /// \param y Y coordinate of pixel to get
////////////////////////////////////////////////////////////
FloatRect GetTexCoords(const IntRect& Rect) const;
////////////////////////////////////////////////////////////
/// Get a valid texture size according to hardware support
/// ///
/// \param Size : Size to convert /// \return Color of the pixel at coordinates (x, y)
/// ///
/// \return Valid nearest size (greater than or equal to specified size ) /// \see setPixel
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static unsigned int GetValidTextureSize(unsigned int Size); Color getPixel(unsigned int x, unsigned int y) const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Assignment operator /// \brief Get a read-only pointer to the array of pixels
/// ///
/// \param Other : instance to assign /// The returned value points to an array of RGBA pixels made of
/// 8 bits integers components. The size of the array is
/// width * height * 4 (getSize().x * getSize().y * 4).
/// Warning: the returned pointer may become invalid if you
/// modify the image, so you should never store it for too long.
/// If the image is empty, a null pointer is returned.
/// ///
/// \return Reference to the image /// \return Read-only pointer to the array of pixels
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Image& operator =(const Image& Other); const Uint8* getPixelsPtr() const;
private :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Create the OpenGL texture /// \brief Flip the image horizontally (left <-> right)
/// ///
/// \return True if texture has been successfully created
///
////////////////////////////////////////////////////////////
bool CreateTexture();
////////////////////////////////////////////////////////////
/// Make sure the texture in video memory is updated with the
/// array of pixels
////////////////////////////////////////////////////////////
void EnsureTextureUpdate() const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Make sure the array of pixels is updated with the void flipHorizontally();
/// texture in video memory
////////////////////////////////////////////////////////////
void EnsureArrayUpdate() const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Reset the image attributes /// \brief Flip the image vertically (top <-> bottom)
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Reset(); void flipVertically();
//////////////////////////////////////////////////////////// private :
/// Destroy the OpenGL texture
///
////////////////////////////////////////////////////////////
void DestroyTexture();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
unsigned int myWidth; ///< Image width Vector2u m_size; ///< Image size
unsigned int myHeight; ///< Image Height std::vector<Uint8> m_pixels; ///< Pixels of the image
unsigned int myTextureWidth; ///< Actual texture wid
th (can be greater than image width because of padding)
unsigned int myTextureHeight; ///< Actual texture hei
ght (can be greater than image height because of padding)
unsigned int myTexture; ///< Internal texture i
dentifier
bool myIsSmooth; ///< Status of the smoo
th filter
mutable std::vector<Color> myPixels; ///< Pixels of the imag
e
mutable bool myNeedTextureUpdate; ///< Status of synchron
ization between pixels in central memory and the internal texture un video
memory
mutable bool myNeedArrayUpdate; ///< Status of synchron
ization between pixels in central memory and the internal texture un video
memory
}; };
} // namespace sf } // namespace sf
#endif // SFML_IMAGE_HPP #endif // SFML_IMAGE_HPP
////////////////////////////////////////////////////////////
/// \class sf::Image
/// \ingroup graphics
///
/// sf::Image is an abstraction to manipulate images
/// as bidimensional arrays of pixels. The class provides
/// functions to load, read, write and save pixels, as well
/// as many other useful functions.
///
/// sf::Image can handle a unique internal representation of
/// pixels, which is RGBA 32 bits. This means that a pixel
/// must be composed of 8 bits red, green, blue and alpha
/// channels -- just like a sf::Color.
/// All the functions that return an array of pixels follow
/// this rule, and all parameters that you pass to sf::Image
/// functions (such as loadFromPixels) must use this
/// representation as well.
///
/// A sf::Image can be copied, but it is a heavy resource and
/// if possible you should always use [const] references to
/// pass or return them to avoid useless copies.
///
/// Usage example:
/// \code
/// // Load an image file from a file
/// sf::Image background;
/// if (!background.loadFromFile("background.jpg"))
/// return -1;
///
/// // Create a 20x20 image filled with black color
/// sf::Image image;
/// if (!image.create(20, 20, sf::Color::Black))
/// return -1;
///
/// // Copy image1 on image2 at position (10, 10)
/// image.copy(background, 10, 10);
///
/// // Make the top-left pixel transparent
/// sf::Color color = image.getPixel(0, 0);
/// color.a = 0;
/// image.setPixel(0, 0, color);
///
/// // Save the image to a file
/// if (!image.saveToFile("result.png"))
/// return -1;
/// \endcode
///
/// \see sf::Texture
///
////////////////////////////////////////////////////////////
 End of changes. 71 change blocks. 
204 lines changed or deleted 119 lines changed or added


 Listener.hpp   Listener.hpp 
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// //
// SFML - Simple and Fast Multimedia Library // SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// //
// This software is provided 'as-is', without any express or implied warran ty. // This software is provided 'as-is', without any express or implied warran ty.
// In no event will the authors be held liable for any damages arising from the use of this software. // 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, // Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it f reely, // including commercial applications, and to alter it and redistribute it f reely,
// subject to the following restrictions: // subject to the following restrictions:
// //
// 1. The origin of this software must not be misrepresented; // 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software. // you must not claim that you wrote the original software.
skipping to change at line 31 skipping to change at line 31
// 3. This notice may not be removed or altered from any source distributio n. // 3. This notice may not be removed or altered from any source distributio n.
// //
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#ifndef SFML_LISTENER_HPP #ifndef SFML_LISTENER_HPP
#define SFML_LISTENER_HPP #define SFML_LISTENER_HPP
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Config.hpp> #include <SFML/Audio/Export.hpp>
#include <SFML/System/Vector3.hpp> #include <SFML/System/Vector3.hpp>
namespace sf namespace sf
{ {
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Listener is a global interface for defining the audio /// \brief The audio listener is the point in the scene
/// listener properties ; the audio listener is the point in /// from where all the sounds are heard
/// the scene from where all the sounds are heard ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class SFML_API Listener class SFML_AUDIO_API Listener
{ {
public : public :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Change the global volume of all the sounds. /// \brief Change the global volume of all the sounds and musics
/// The default volume is 100
/// ///
/// \param Volume : New global volume, in the range [0, 100] /// The volume is a number between 0 and 100; it is combined with
/// the individual volume of each sound / music.
/// The default value for the volume is 100 (maximum).
///
/// \param volume New global volume, in the range [0, 100]
///
/// \see getGlobalVolume
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static void SetGlobalVolume(float Volume); static void setGlobalVolume(float volume);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the current value of the global volume of all the sounds /// \brief Get the current value of the global volume
/// ///
/// \return Current global volume, in the range [0, 100] /// \return Current global volume, in the range [0, 100]
/// ///
/// \see setGlobalVolume
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static float GetGlobalVolume(); static float getGlobalVolume();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Change the position of the listener (take 3 values). /// \brief Set the position of the listener in the scene
/// The default position is (0, 0, 0) ///
/// The default listener's position is (0, 0, 0).
/// ///
/// \param X, Y, Z : Position of the listener in the world /// \param x X coordinate of the listener's position
/// \param y Y coordinate of the listener's position
/// \param z Z coordinate of the listener's position
///
/// \see getPosition, setDirection
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static void SetPosition(float X, float Y, float Z); static void setPosition(float x, float y, float z);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Change the position of the listener (take a 3D vector). /// \brief Set the position of the listener in the scene
/// The default position is (0, 0, 0) ///
/// The default listener's position is (0, 0, 0).
/// ///
/// \param Position : Position of the listener in the world /// \param position New listener's position
///
/// \see getPosition, setDirection
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static void SetPosition(const Vector3f& Position); static void setPosition(const Vector3f& position);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the current position of the listener /// \brief Get the current position of the listener in the scene
///
/// \return Listener's position
/// ///
/// \return Position of the listener in the world /// \see setPosition
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static Vector3f GetPosition(); static Vector3f getPosition();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Change the orientation of the listener (the point /// \brief Set the orientation of the listener in the scene
/// he must look at) (take 3 values).
/// The default target is (0, 0, -1)
/// ///
/// \param X, Y, Z : Position of the point the listener must look at /// The orientation defines the 3D axes of the listener
/// (left, up, front) in the scene. The orientation vector
/// doesn't have to be normalized.
/// The default listener's orientation is (0, 0, -1).
///
/// \param x X coordinate of the listener's orientation
/// \param y Y coordinate of the listener's orientation
/// \param z Z coordinate of the listener's orientation
///
/// \see getDirection, setPosition
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static void SetTarget(float X, float Y, float Z); static void setDirection(float x, float y, float z);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Change the orientation of the listener (the point /// \brief Set the orientation of the listener in the scene
/// he must look at) (take a 3D vector). ///
/// The default target is (0, 0, -1) /// The orientation defines the 3D axes of the listener
/// (left, up, front) in the scene. The orientation vector
/// doesn't have to be normalized.
/// The default listener's orientation is (0, 0, -1).
///
/// \param direction New listener's orientation
/// ///
/// \param Target : Position of the point the listener must look at /// \see getDirection, setPosition
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static void SetTarget(const Vector3f& Target); static void setDirection(const Vector3f& direction);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the current orientation of the listener (the point /// \brief Get the current orientation of the listener in the scene
/// he's looking at)
/// ///
/// \return : Position of the point the listener is looking at /// \return Listener's orientation
///
/// \see setDirection
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static Vector3f GetTarget(); static Vector3f getDirection();
}; };
} // namespace sf } // namespace sf
#endif // SFML_LISTENER_HPP #endif // SFML_LISTENER_HPP
////////////////////////////////////////////////////////////
/// \class sf::Listener
/// \ingroup audio
///
/// The audio listener defines the global properties of the
/// audio environment, it defines where and how sounds and musics
/// are heard. If sf::View is the eyes of the user, then sf::Listener
/// is his ears (by the way, they are often linked together --
/// same position, orientation, etc.).
///
/// sf::Listener is a simple interface, which allows to setup the
/// listener in the 3D audio environment (position and direction),
/// and to adjust the global volume.
///
/// Because the listener is unique in the scene, sf::Listener only
/// contains static functions and doesn't have to be instanciated.
///
/// Usage example:
/// \code
/// // Move the listener to the position (1, 0, -5)
/// sf::Listener::setPosition(1, 0, -5);
///
/// // Make it face the right axis (1, 0, 0)
/// sf::Listener::setDirection(1, 0, 0);
///
/// // Reduce the global volume
/// sf::Listener::setGlobalVolume(50);
/// \endcode
///
////////////////////////////////////////////////////////////
 End of changes. 29 change blocks. 
37 lines changed or deleted 67 lines changed or added


 Lock.hpp   Lock.hpp 
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// //
// SFML - Simple and Fast Multimedia Library // SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// //
// This software is provided 'as-is', without any express or implied warran ty. // This software is provided 'as-is', without any express or implied warran ty.
// In no event will the authors be held liable for any damages arising from the use of this software. // 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, // Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it f reely, // including commercial applications, and to alter it and redistribute it f reely,
// subject to the following restrictions: // subject to the following restrictions:
// //
// 1. The origin of this software must not be misrepresented; // 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software. // you must not claim that you wrote the original software.
skipping to change at line 31 skipping to change at line 31
// 3. This notice may not be removed or altered from any source distributio n. // 3. This notice may not be removed or altered from any source distributio n.
// //
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#ifndef SFML_LOCK_HPP #ifndef SFML_LOCK_HPP
#define SFML_LOCK_HPP #define SFML_LOCK_HPP
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/System/Export.hpp>
#include <SFML/System/NonCopyable.hpp> #include <SFML/System/NonCopyable.hpp>
namespace sf namespace sf
{ {
class Mutex; class Mutex;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Lock is an exception-safe automatic wrapper for /// \brief Automatic wrapper for locking and unlocking mutexes
/// locking and unlocking mutexes ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class SFML_API Lock : NonCopyable class SFML_SYSTEM_API Lock : NonCopyable
{ {
public : public :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Construct the lock with a target mutex (lock it) /// \brief Construct the lock with a target mutex
/// ///
/// @param Mutex : Mutex to lock /// The mutex passed to sf::Lock is automatically locked.
///
/// \param mutex Mutex to lock
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Lock(Mutex& Mutex); explicit Lock(Mutex& mutex);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destructor (unlocks the mutex) /// \brief Destructor
///
/// The destructor of sf::Lock automatically unlocks its mutex.
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
~Lock(); ~Lock();
private : private :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Mutex& myMutex; ///< Mutex to lock / unlock Mutex& m_mutex; ///< Mutex to lock / unlock
}; };
} // namespace sf } // namespace sf
#endif // SFML_LOCK_HPP #endif // SFML_LOCK_HPP
////////////////////////////////////////////////////////////
/// \class sf::Lock
/// \ingroup system
///
/// sf::Lock is a RAII wrapper for sf::Mutex. By unlocking
/// it in its destructor, it ensures that the mutex will
/// always be released when the current scope (most likely
/// a function) ends.
/// This is even more important when an exception or an early
/// return statement can interrupt the execution flow of the
/// function.
///
/// For maximum robustness, sf::Lock should always be used
/// to lock/unlock a mutex.
///
/// Usage example:
/// \code
/// sf::Mutex mutex;
///
/// void function()
/// {
/// sf::Lock lock(mutex); // mutex is now locked
///
/// functionThatMayThrowAnException(); // mutex is unlocked if this fun
ction throws
///
/// if (someCondition)
/// return; // mutex is unlocked
///
/// } // mutex is unlocked
/// \endcode
///
/// Because the mutex is not explicitely unlocked in the code,
/// it may remain locked longer than needed. If the region
/// of the code that needs to be protected by the mutex is
/// not the entire function, a good practice is to create a
/// smaller, inner scope so that the lock is limited to this
/// part of the code.
///
/// \code
/// sf::Mutex mutex;
///
/// void function()
/// {
/// {
/// sf::Lock lock(mutex);
/// codeThatRequiresProtection();
///
/// } // mutex is unlocked here
///
/// codeThatDoesntCareAboutTheMutex();
/// }
/// \endcode
///
/// Having a mutex locked longer than required is a bad practice
/// which can lead to bad performances. Don't forget that when
/// a mutex is locked, other threads may be waiting doing nothing
/// until it is released.
///
/// \see sf::Mutex
///
////////////////////////////////////////////////////////////
 End of changes. 10 change blocks. 
9 lines changed or deleted 14 lines changed or added


 Music.hpp   Music.hpp 
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// //
// SFML - Simple and Fast Multimedia Library // SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// //
// This software is provided 'as-is', without any express or implied warran ty. // This software is provided 'as-is', without any express or implied warran ty.
// In no event will the authors be held liable for any damages arising from the use of this software. // 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, // Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it f reely, // including commercial applications, and to alter it and redistribute it f reely,
// subject to the following restrictions: // subject to the following restrictions:
// //
// 1. The origin of this software must not be misrepresented; // 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software. // you must not claim that you wrote the original software.
skipping to change at line 31 skipping to change at line 31
// 3. This notice may not be removed or altered from any source distributio n. // 3. This notice may not be removed or altered from any source distributio n.
// //
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#ifndef SFML_MUSIC_HPP #ifndef SFML_MUSIC_HPP
#define SFML_MUSIC_HPP #define SFML_MUSIC_HPP
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Audio/Export.hpp>
#include <SFML/Audio/SoundStream.hpp> #include <SFML/Audio/SoundStream.hpp>
#include <SFML/System/Mutex.hpp>
#include <SFML/System/Time.hpp>
#include <string> #include <string>
#include <vector> #include <vector>
namespace sf namespace sf
{ {
namespace priv namespace priv
{ {
class SoundFile; class SoundFile;
} }
class InputStream;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Music defines a big sound played using streaming, /// \brief Streamed music played from an audio file
/// so usually what we call a music :) ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class SFML_API Music : public SoundStream class SFML_AUDIO_API Music : public SoundStream
{ {
public : public :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Construct the music with a buffer size /// \brief Default constructor
///
/// \param BufferSize : Size of the internal buffer, expressed in numbe
r of samples
/// (ie. size taken by the music in memory) (44100
by default)
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
explicit Music(std::size_t BufferSize = 44100); Music();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Destructor /// \brief Destructor
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
~Music(); ~Music();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Open a music file (doesn't play it -- call Play() for that) /// \brief Open a music from an audio file
///
/// This function doesn't start playing the music (call play()
/// to do so).
/// Here is a complete list of all the supported audio formats:
/// ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam,
/// w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.
///
/// \param filename Path of the music file to open
/// ///
/// \param Filename : Path of the music file to open /// \return True if loading succeeded, false if it failed
/// ///
/// \return True if loading has been successful /// \see openFromMemory, openFromStream
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
bool OpenFromFile(const std::string& Filename); bool openFromFile(const std::string& filename);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Open a music file from memory (doesn't play it -- call Play() for t hat) /// \brief Open a music from an audio file in memory
/// ///
/// \param Data : Pointer to the file data in memory /// This function doesn't start playing the music (call play()
/// \param SizeInBytes : Size of the data to load, in bytes /// to do so).
/// Here is a complete list of all the supported audio formats:
/// ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam,
/// w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.
/// Since the music is not loaded completely but rather streamed
/// continuously, the \a data must remain available as long as the
/// music is playing (ie. you can't deallocate it right after calling
/// this function).
/// ///
/// \return True if loading has been successful /// \param data Pointer to the file data in memory
/// \param sizeInBytes Size of the data to load, in bytes
///
/// \return True if loading succeeded, false if it failed
///
/// \see openFromFile, openFromStream
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
bool OpenFromMemory(const char* Data, std::size_t SizeInBytes); bool openFromMemory(const void* data, std::size_t sizeInBytes);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the music duration /// \brief Open a music from an audio file in a custom stream
///
/// This function doesn't start playing the music (call play()
/// to do so).
/// Here is a complete list of all the supported audio formats:
/// ogg, wav, flac, aiff, au, raw, paf, svx, nist, voc, ircam,
/// w64, mat4, mat5 pvf, htk, sds, avr, sd2, caf, wve, mpc2k, rf64.
/// Since the music is not loaded completely but rather streamed
/// continuously, the \a stream must remain alive as long as the
/// music is playing (ie. you can't destroy it right after calling
/// this function).
/// ///
/// \return Music duration, in seconds /// \param stream Source stream to read from
///
/// \return True if loading succeeded, false if it failed
///
/// \see openFromFile, openFromMemory
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
float GetDuration() const; bool openFromStream(InputStream& stream);
private : ////////////////////////////////////////////////////////////
/// \brief Get the total duration of the music
///
/// \return Music duration
///
////////////////////////////////////////////////////////////
Time getDuration() const;
protected :
////////////////////////////////////////////////////////////
/// \brief Request a new chunk of audio samples from the stream source
///
/// This function fills the chunk from the next samples
/// to read from the audio file.
///
/// \param data Chunk of data to fill
///
/// \return True to continue playback, false to stop
///
////////////////////////////////////////////////////////////
virtual bool onGetData(Chunk& data);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// /see SoundStream::OnStart /// \brief Change the current playing position in the stream source
///
/// \param timeOffset New playing position, from the beginning of the m
usic
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
virtual bool OnStart(); virtual void onSeek(Time timeOffset);
private :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// /see SoundStream::OnGetData /// \brief Initialize the internal state after loading a new music
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
virtual bool OnGetData(Chunk& Data); void initialize();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
priv::SoundFile* myFile; ///< Sound file priv::SoundFile* m_file; ///< Sound file
float myDuration; ///< Music duration, in seconds Time m_duration; ///< Music duration
std::vector<Int16> mySamples; ///< Temporary buffer of samples std::vector<Int16> m_samples; ///< Temporary buffer of samples
Mutex m_mutex; ///< Mutex protecting the data
}; };
} // namespace sf } // namespace sf
#endif // SFML_MUSIC_HPP #endif // SFML_MUSIC_HPP
////////////////////////////////////////////////////////////
/// \class sf::Music
/// \ingroup audio
///
/// Musics are sounds that are streamed rather than completely
/// loaded in memory. This is especially useful for compressed
/// musics that usually take hundreds of MB when they are
/// uncompressed: by streaming it instead of loading it entirely,
/// you avoid saturating the memory and have almost no loading delay.
///
/// Apart from that, a sf::Music has almost the same features as
/// the sf::SoundBuffer / sf::Sound pair: you can play/pause/stop
/// it, request its parameters (channels, sample rate), change
/// the way it is played (pitch, volume, 3D position, ...), etc.
///
/// As a sound stream, a music is played in its own thread in order
/// not to block the rest of the program. This means that you can
/// leave the music alone after calling play(), it will manage itself
/// very well.
///
/// Usage example:
/// \code
/// // Declare a new music
/// sf::Music music;
///
/// // Open it from an audio file
/// if (!music.openFromFile("music.ogg"))
/// {
/// // error...
/// }
///
/// // Change some parameters
/// music.setPosition(0, 1, 10); // change its 3D position
/// music.setPitch(2); // increase the pitch
/// music.setVolume(50); // reduce the volume
/// music.setLoop(true); // make it loop
///
/// // Play it
/// music.play();
/// \endcode
///
/// \see sf::Sound, sf::SoundStream
///
////////////////////////////////////////////////////////////
 End of changes. 27 change blocks. 
32 lines changed or deleted 93 lines changed or added


 Mutex.hpp   Mutex.hpp 
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// //
// SFML - Simple and Fast Multimedia Library // SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// //
// This software is provided 'as-is', without any express or implied warran ty. // This software is provided 'as-is', without any express or implied warran ty.
// In no event will the authors be held liable for any damages arising from the use of this software. // 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, // Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it f reely, // including commercial applications, and to alter it and redistribute it f reely,
// subject to the following restrictions: // subject to the following restrictions:
// //
// 1. The origin of this software must not be misrepresented; // 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software. // you must not claim that you wrote the original software.
skipping to change at line 31 skipping to change at line 31
// 3. This notice may not be removed or altered from any source distributio n. // 3. This notice may not be removed or altered from any source distributio n.
// //
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#ifndef SFML_MUTEX_HPP #ifndef SFML_MUTEX_HPP
#define SFML_MUTEX_HPP #define SFML_MUTEX_HPP
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Config.hpp> #include <SFML/System/Export.hpp>
#include <SFML/System/NonCopyable.hpp>
#ifdef SFML_SYSTEM_WINDOWS namespace sf
{
namespace priv
{
class MutexImpl;
}
#include <SFML/System/Win32/Mutex.hpp> ////////////////////////////////////////////////////////////
/// \brief Blocks concurrent access to shared resources
#else /// from multiple threads
///
#include <SFML/System/Unix/Mutex.hpp> ////////////////////////////////////////////////////////////
class SFML_SYSTEM_API Mutex : NonCopyable
{
public :
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
////////////////////////////////////////////////////////////
Mutex();
////////////////////////////////////////////////////////////
/// \brief Destructor
///
////////////////////////////////////////////////////////////
~Mutex();
////////////////////////////////////////////////////////////
/// \brief Lock the mutex
///
/// If the mutex is already locked in another thread,
/// this call will block the execution until the mutex
/// is released.
///
/// \see unlock
///
////////////////////////////////////////////////////////////
void lock();
////////////////////////////////////////////////////////////
/// \brief Unlock the mutex
///
/// \see lock
///
////////////////////////////////////////////////////////////
void unlock();
private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
priv::MutexImpl* m_mutexImpl; ///< OS-specific implementation
};
#endif } // namespace sf
#endif // SFML_MUTEX_HPP #endif // SFML_MUTEX_HPP
////////////////////////////////////////////////////////////
/// \class sf::Mutex
/// \ingroup system
///
/// Mutex stands for "MUTual EXclusion". A mutex is a
/// synchronization object, used when multiple threads are involved.
///
/// When you want to protect a part of the code from being accessed
/// simultaneously by multiple threads, you typically use a
/// mutex. When a thread is locked by a mutex, any other thread
/// trying to lock it will be blocked until the mutex is released
/// by the thread that locked it. This way, you can allow only
/// one thread at a time to access a critical region of your code.
///
/// Usage example:
/// \code
/// Database database; // this is a critical resource that needs some prote
ction
/// sf::Mutex mutex;
///
/// void thread1()
/// {
/// mutex.lock(); // this call will block the thread if the mutex is al
ready locked by thread2
/// database.write(...);
/// mutex.unlock(); // if thread2 was waiting, it will now be unblocked
/// }
///
/// void thread2()
/// {
/// mutex.lock(); // this call will block the thread if the mutex is al
ready locked by thread1
/// database.write(...);
/// mutex.unlock(); // if thread1 was waiting, it will now be unblocked
/// }
/// \endcode
///
/// Be very careful with mutexes. A bad usage can lead to bad problems,
/// like deadlocks (two threads are waiting for each other and the
/// application is globally stuck).
///
/// To make the usage of mutexes more robust, particularly in
/// environments where exceptions can be thrown, you should
/// use the helper class sf::Lock to lock/unlock mutexes.
///
/// SFML mutexes are recursive, which means that you can lock
/// a mutex multiple times in the same thread without creating
/// a deadlock. In this case, the first call to lock() behaves
/// as usual, and the following ones have no effect.
/// However, you must call unlock() exactly as many times as you
/// called lock(). If you don't, the mutex won't be released.
///
/// \see sf::Lock
///
////////////////////////////////////////////////////////////
 End of changes. 6 change blocks. 
9 lines changed or deleted 58 lines changed or added


 Network.hpp   Network.hpp 
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// //
// SFML - Simple and Fast Multimedia Library // SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// //
// This software is provided 'as-is', without any express or implied warran ty. // This software is provided 'as-is', without any express or implied warran ty.
// In no event will the authors be held liable for any damages arising from the use of this software. // 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, // Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it f reely, // including commercial applications, and to alter it and redistribute it f reely,
// subject to the following restrictions: // subject to the following restrictions:
// //
// 1. The origin of this software must not be misrepresented; // 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software. // you must not claim that you wrote the original software.
skipping to change at line 35 skipping to change at line 35
#ifndef SFML_NETWORK_HPP #ifndef SFML_NETWORK_HPP
#define SFML_NETWORK_HPP #define SFML_NETWORK_HPP
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/System.hpp> #include <SFML/System.hpp>
#include <SFML/Network/Ftp.hpp> #include <SFML/Network/Ftp.hpp>
#include <SFML/Network/Http.hpp> #include <SFML/Network/Http.hpp>
#include <SFML/Network/IPAddress.hpp> #include <SFML/Network/IpAddress.hpp>
#include <SFML/Network/Packet.hpp> #include <SFML/Network/Packet.hpp>
#include <SFML/Network/Selector.hpp> #include <SFML/Network/SocketSelector.hpp>
#include <SFML/Network/SocketTCP.hpp> #include <SFML/Network/TcpListener.hpp>
#include <SFML/Network/SocketUDP.hpp> #include <SFML/Network/TcpSocket.hpp>
#include <SFML/Network/UdpSocket.hpp>
#endif // SFML_NETWORK_HPP #endif // SFML_NETWORK_HPP
////////////////////////////////////////////////////////////
/// \defgroup network Network module
///
/// Socket-based communication, utilities and higher-level
/// network protocols (HTTP, FTP).
///
////////////////////////////////////////////////////////////
 End of changes. 4 change blocks. 
5 lines changed or deleted 6 lines changed or added


 NonCopyable.hpp   NonCopyable.hpp 
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// //
// SFML - Simple and Fast Multimedia Library // SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// //
// This software is provided 'as-is', without any express or implied warran ty. // This software is provided 'as-is', without any express or implied warran ty.
// In no event will the authors be held liable for any damages arising from the use of this software. // 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, // Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it f reely, // including commercial applications, and to alter it and redistribute it f reely,
// subject to the following restrictions: // subject to the following restrictions:
// //
// 1. The origin of this software must not be misrepresented; // 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software. // you must not claim that you wrote the original software.
skipping to change at line 31 skipping to change at line 31
// 3. This notice may not be removed or altered from any source distributio n. // 3. This notice may not be removed or altered from any source distributio n.
// //
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#ifndef SFML_NONCOPYABLE_HPP #ifndef SFML_NONCOPYABLE_HPP
#define SFML_NONCOPYABLE_HPP #define SFML_NONCOPYABLE_HPP
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Config.hpp> #include <SFML/System/Export.hpp>
namespace sf namespace sf
{ {
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Utility base class to easily declare non-copyable classes. /// \brief Utility class that makes any derived
/// Just inherit from NonCopyable to get a non-copyable class /// class non-copyable
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
struct SFML_API NonCopyable class SFML_SYSTEM_API NonCopyable
{ {
protected : protected :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// The default constructor won't be generated, so provide it /// \brief Default constructor
///
/// Because this class has a copy constructor, the compiler
/// will not automatically generate the default constructor.
/// That's why we must define it explicitely.
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
NonCopyable() {} NonCopyable() {}
private : private :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Copy constructor : declare it private and don't implement /// \brief Disabled copy constructor
/// it to prevent from calling it ///
/// By making the copy constructor private, the compiler will
/// trigger an error if anyone outside tries to use it.
/// To prevent NonCopyable or friend classes from using it,
/// we also give no definition, so that the linker will
/// produce an error if the first protection was inefficient.
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
NonCopyable(const NonCopyable&); NonCopyable(const NonCopyable&);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Assignment operator : declare it private and don't implement /// \brief Disabled assignment operator
/// it to prevent from calling it ///
/// By making the assignment operator private, the compiler will
/// trigger an error if anyone outside tries to use it.
/// To prevent NonCopyable or friend classes from using it,
/// we also give no definition, so that the linker will
/// produce an error if the first protection was inefficient.
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
NonCopyable& operator =(const NonCopyable&); NonCopyable& operator =(const NonCopyable&);
}; };
} // namespace sf } // namespace sf
#endif // SFML_NONCOPYABLE_HPP #endif // SFML_NONCOPYABLE_HPP
////////////////////////////////////////////////////////////
/// \class sf::NonCopyable
/// \ingroup system
///
/// This class makes its instances non-copyable, by explicitely
/// disabling its copy constructor and its assignment operator.
///
/// To create a non-copyable class, simply inherit from
/// sf::NonCopyable.
///
/// The type of inheritance (public or private) doesn't matter,
/// the copy constructor and assignment operator are declared private
/// in sf::NonCopyable so they will end up being inaccessible in both
/// cases. Thus you can use a shorter syntax for inheriting from it
/// (see below).
///
/// Usage example:
/// \code
/// class MyNonCopyableClass : sf::NonCopyable
/// {
/// ...
/// };
/// \endcode
///
/// Deciding whether the instances of a class can be copied
/// or not is a very important design choice. You are strongly
/// encouraged to think about it before writing a class,
/// and to use sf::NonCopyable when necessary to prevent
/// many potential future errors when using it. This is also
/// a very important indication to users of your class.
///
////////////////////////////////////////////////////////////
 End of changes. 8 change blocks. 
10 lines changed or deleted 25 lines changed or added


 OpenGL.hpp   OpenGL.hpp 
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// //
// SFML - Simple and Fast Multimedia Library // SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// //
// This software is provided 'as-is', without any express or implied warran ty. // This software is provided 'as-is', without any express or implied warran ty.
// In no event will the authors be held liable for any damages arising from the use of this software. // 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, // Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it f reely, // including commercial applications, and to alter it and redistribute it f reely,
// subject to the following restrictions: // subject to the following restrictions:
// //
// 1. The origin of this software must not be misrepresented; // 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software. // you must not claim that you wrote the original software.
skipping to change at line 39 skipping to change at line 39
/// Headers /// Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Config.hpp> #include <SFML/Config.hpp>
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// This file just includes the OpenGL (GL and GLU) headers, /// This file just includes the OpenGL (GL and GLU) headers,
/// which have actually different paths on each system /// which have actually different paths on each system
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#if defined(SFML_SYSTEM_WINDOWS) #if defined(SFML_SYSTEM_WINDOWS)
#include <windows.h> // The Visual C++ version of gl.h uses WINGDIAPI and APIENTRY but doesn
't define them
#ifdef _MSC_VER
#include <windows.h>
#endif
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glu.h> #include <GL/glu.h>
#elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD) #elif defined(SFML_SYSTEM_LINUX) || defined(SFML_SYSTEM_FREEBSD)
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glu.h> #include <GL/glu.h>
#elif defined(SFML_SYSTEM_MACOS) #elif defined(SFML_SYSTEM_MACOS)
 End of changes. 2 change blocks. 
2 lines changed or deleted 7 lines changed or added


 Packet.hpp   Packet.hpp 
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// //
// SFML - Simple and Fast Multimedia Library // SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com) // Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
// //
// This software is provided 'as-is', without any express or implied warran ty. // This software is provided 'as-is', without any express or implied warran ty.
// In no event will the authors be held liable for any damages arising from the use of this software. // 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, // Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it f reely, // including commercial applications, and to alter it and redistribute it f reely,
// subject to the following restrictions: // subject to the following restrictions:
// //
// 1. The origin of this software must not be misrepresented; // 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software. // you must not claim that you wrote the original software.
skipping to change at line 31 skipping to change at line 31
// 3. This notice may not be removed or altered from any source distributio n. // 3. This notice may not be removed or altered from any source distributio n.
// //
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#ifndef SFML_PACKET_HPP #ifndef SFML_PACKET_HPP
#define SFML_PACKET_HPP #define SFML_PACKET_HPP
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Config.hpp> #include <SFML/Network/Export.hpp>
#include <string> #include <string>
#include <vector> #include <vector>
namespace sf namespace sf
{ {
class String;
class TcpSocket;
class UdpSocket;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Packet wraps data to send / to receive through the network /// \brief Utility class to build blocks of data to transfer
/// over the network
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
class SFML_API Packet class SFML_NETWORK_API Packet
{ {
// A bool-like type that cannot be converted to integer or pointer type
s
typedef bool (Packet::*BoolType)(std::size_t);
public : public :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Default constructor /// \brief Default constructor
///
/// Creates an empty packet.
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Packet(); Packet();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Virtual destructor /// \brief Virtual destructor
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
virtual ~Packet(); virtual ~Packet();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Append data to the end of the packet /// \brief Append data to the end of the packet
/// ///
/// \param Data : Pointer to the bytes to append /// \param data Pointer to the sequence of bytes to append
/// \param SizeInBytes : Number of bytes to append /// \param sizeInBytes Number of bytes to append
///
/// \see clear
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Append(const void* Data, std::size_t SizeInBytes); void append(const void* data, std::size_t sizeInBytes);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Clear the packet data /// \brief Clear the packet
///
/// After calling Clear, the packet is empty.
///
/// \see append
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Clear(); void clear();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get a pointer to the data contained in the packet /// \brief Get a pointer to the data contained in the packet
/// Warning : the returned pointer may be invalid after you ///
/// append data to the packet /// Warning: the returned pointer may become invalid after
/// you append data to the packet, therefore it should never
/// be stored.
/// The return pointer is NULL if the packet is empty.
/// ///
/// \return Pointer to the data /// \return Pointer to the data
/// ///
/// \see getDataSize
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const char* GetData() const; const void* getData() const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the size of the data contained in the packet /// \brief Get the size of the data contained in the packet
///
/// This function returns the number of bytes pointed to by
/// what getData returns.
/// ///
/// \return Data size, in bytes /// \return Data size, in bytes
/// ///
/// \see getData
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
std::size_t GetDataSize() const; </