Fixed header <iterator> missing in the voip sample

Minor additions to the API documentation of the drawable classes

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1520 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2010-05-13 11:00:29 +00:00
parent aade008582
commit aaf080368b
9 changed files with 307 additions and 129 deletions

View File

@ -239,132 +239,212 @@ public :
/// ///
/// This global color affects the entire object, and modulates /// This global color affects the entire object, and modulates
/// (multiplies) its original pixels. /// (multiplies) its original pixels.
/// The default color is white.
/// ///
/// The default color is white /// \param color New color
/// ///
/// \param color : New color /// \see GetColor
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void SetColor(const Color& color); void SetColor(const Color& color);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Set the blending mode for the object. /// \brief Set the blending mode of the object
/// The default blend mode is Blend::Alpha
/// ///
/// \param mode : New blending mode /// This property defines how the pixels of an object are
/// blended with the pixels of the render target to which
/// it is drawn. To know more about the blending modes
/// available, see the sf::Blend::Mode enum.
/// The default blend mode is Blend::Alpha.
///
/// \param mode New blending mode
///
/// \see GetBlendMode
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void SetBlendMode(Blend::Mode mode); void SetBlendMode(Blend::Mode mode);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the position of the object /// \brief Get the position of the object
/// ///
/// \return Current position /// \return Current position
/// ///
/// \see SetPosition
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const Vector2f& GetPosition() const; const Vector2f& GetPosition() const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the current scale of the object /// \brief Get the current scale of the object
/// ///
/// \return Current scale factor (always positive) /// \return Current scale factors
///
/// \see SetScale
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const Vector2f& GetScale() const; const Vector2f& GetScale() const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the local origin of the object /// \brief Get the local origin of the object
/// ///
/// \return Current position of the origin /// \return Current origin
///
/// \see SetOrigin
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const Vector2f& GetOrigin() const; const Vector2f& GetOrigin() const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the orientation of the object. /// \brief Get the orientation of the object
/// Rotation is always in the range [0, 360] ///
/// The rotation is always in the range [0, 360].
/// ///
/// \return Current rotation, in degrees /// \return Current rotation, in degrees
/// ///
/// \see SetRotation
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
float GetRotation() const; float GetRotation() const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the color of the object /// \brief Get the color of the object
/// ///
/// \return Current color /// \return Current color
/// ///
/// \see SetColor
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const Color& GetColor() const; const Color& GetColor() const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the current blending mode /// \brief Get the blend mode of the object
/// ///
/// \return Current blending mode /// \return Current blend mode
///
/// \see SetBlendMode
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Blend::Mode GetBlendMode() const; Blend::Mode GetBlendMode() const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Move the object of a given offset (take 2 values) /// \brief Move the object by a given offset
/// ///
/// \param offsetX : X offset /// This function adds to the current position of the object,
/// \param offsetY : Y offset /// unlike SetPosition which overwrites it.
/// Thus, it is equivalent to the following code:
/// \code
/// sf::Vector2f pos = object.GetPosition();
/// object.SetPosition(pos.x + offsetX, pos.y + offsetY);
/// \endcode
///
/// \param offsetX X offset
/// \param offsetY Y offset
///
/// \see SetPosition
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Move(float offsetX, float offsetY); void Move(float offsetX, float offsetY);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Move the object of a given offset (take a 2D vector) /// \brief Move the object by a given offset
/// ///
/// \param offset : Amount of units to move the object of /// This function adds to the current position of the object,
/// unlike SetPosition which overwrites it.
/// Thus, it is equivalent to the following code:
/// \code
/// object.SetPosition(object.GetPosition() + offset);
/// \endcode
///
/// \param offset Offset
///
/// \see SetPosition
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Move(const Vector2f& offset); void Move(const Vector2f& offset);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Scale the object (take 2 values) /// \brief Scale the object
/// ///
/// \param factorX : Scaling factor on X (must be strictly positive) /// This function multiplies the current scale of the object,
/// \param factorY : Scaling factor on Y (must be strictly positive) /// unlike SetScale which overwrites it.
/// Thus, it is equivalent to the following code:
/// \code
/// sf::Vector2f scale = object.GetScale();
/// object.SetScale(scale.x * factorX, scale.y * factorY);
/// \endcode
///
/// \param factorX Horizontal scale factor
/// \param factorY Vertical scale factor
///
/// \see SetScale
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Scale(float factorX, float factorY); void Scale(float factorX, float factorY);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Scale the object (take a 2D vector) /// \brief Scale the object
/// ///
/// \param factor : Scaling factors (both values must be strictly positive) /// This function multiplies the current scale of the object,
/// unlike SetScale which overwrites it.
/// Thus, it is equivalent to the following code:
/// \code
/// sf::Vector2f scale = object.GetScale();
/// object.SetScale(scale.x * factor.x, scale.y * factor.y);
/// \endcode
///
/// \param factor Scale factors
///
/// \see SetScale
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Scale(const Vector2f& factor); void Scale(const Vector2f& factor);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Rotate the object /// \brief Rotate the object
/// ///
/// \param Angle : Angle of rotation, in degrees /// This function ads to the current rotation of the object,
/// unlike SetRotation which overwrites it.
/// Thus, it is equivalent to the following code:
/// \code
/// object.SetRotation(object.GetRotation() + angle);
/// \endcode
///
/// \param angle Angle of rotation, in degrees
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Rotate(float Angle); void Rotate(float angle);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Transform a point from global coordinates into local coordinates /// \brief Transform a point in object local coordinates
/// (ie it applies the inverse of object's origin, translation, rotation and scale to the point)
/// ///
/// \param point : Point to transform /// This function takes a point in global coordinates, and
/// transforms it in coordinates local to the object.
/// In other words, it applies the inverse of all the
/// transformations applied to the object (origin,
/// translation, rotation and scale).
/// ///
/// \return Transformed point /// \param point Point to transform
///
/// \return The transformed point
///
/// \see TransformToGlobal
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Vector2f TransformToLocal(const Vector2f& point) const; Vector2f TransformToLocal(const Vector2f& point) const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Transform a point from local coordinates into global coordinates /// \brief Transform a local point in global coordinates
/// (ie it applies the object's origin, translation, rotation and scale to the point)
/// ///
/// \param point : Point to transform /// This function takes a point in local coordinates, and
/// transforms it in global coordinates. In other words,
/// it applies the same transformations that are applied
/// to the object (origin, translation, rotation and scale).
/// ///
/// \return Transformed point /// \param point Point to transform
///
/// \return The transformed point
///
/// \see TransformToLocal
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Vector2f TransformToGlobal(const Vector2f& point) const; Vector2f TransformToGlobal(const Vector2f& point) const;
@ -372,18 +452,22 @@ public :
protected : protected :
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the transform matrix of the drawable /// \brief Get the transform matrix of the object
/// ///
/// \return Transform matrix /// \return Transform matrix
/// ///
/// \see GetInverseMatrix
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const Matrix3& GetMatrix() const; const Matrix3& GetMatrix() const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Get the inverse transform matrix of the drawable /// \brief Get the inverse transform matrix of the object
/// ///
/// \return Inverse transform matrix /// \return Inverse transform matrix
/// ///
/// \see GetMatrix
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const Matrix3& GetInverseMatrix() const; const Matrix3& GetInverseMatrix() const;
@ -392,19 +476,27 @@ private :
friend class RenderTarget; friend class RenderTarget;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Draw the object into the specified render target /// \brief Draw the object to a render target
/// ///
/// \param target : Target into which render the object /// This function applies the common states of the object,
/// \param renderer : Renderer that processes the rendering commands /// then calls the virtual Render functions to let the derived
/// class draw the geometry of the object.
///
/// \param target Render target
/// \param renderer Renderer providing low-level rendering commands
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Draw(RenderTarget& target, Renderer& renderer) const; void Draw(RenderTarget& target, Renderer& renderer) const;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Render the specific geometry of the object /// \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
/// \param renderer : Renderer that processes the rendering commands /// by the derived class to define how the drawable should be
/// rendered.
///
/// \param target Render target
/// \param renderer Renderer providing low-level rendering commands
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
virtual void Render(RenderTarget& target, Renderer& renderer) const = 0; virtual void Render(RenderTarget& target, Renderer& renderer) const = 0;
@ -428,3 +520,80 @@ private :
#endif // SFML_DRAWABLE_HPP #endif // SFML_DRAWABLE_HPP
////////////////////////////////////////////////////////////
/// \class sf::Drawable
///
/// sf::Drawable defines the attributes and operations that
/// are common to all the drawable classes:
/// \li transformations (position, rotation, scale, local origin)
/// \li global overlay color
/// \li blending mode with background pixels
/// \li the ability to be drawn on a sf::RenderTarget (either RenderWindow or RenderImage)
///
/// Please note that all these attributes are hardware accelerated,
/// therefore they are extremely cheap to use (unlike older
/// libraries that perform slow transformations on the CPU, such as
/// rotation or scale).
///
/// Usage example:
/// \code
/// // Here we'll use a sf::Sprite to demonstrate the features of sf::Drawable
/// sf::Sprite drawable = /* ...whatever... */;
///
/// drawable.SetOrigin(10, 20); // set its origin to the local point (10, 20)
/// drawable.SetPosition(100, 100); // set its position to (100, 100)
/// drawable.SetRotation(45); // set its orientation to 45 degrees
/// drawable.SetColor(sf::Color::Red); // set its global color to red
/// drawable.SetBlendingMode(sf::Blend::Add); // set an additive blend mode
///
/// window.Draw(drawable); // finally draw it (window is a sf::RenderWindow)
/// \endcode
///
/// Deriving your own class from sf::Drawable is possible, however
/// you have to use the sf::Renderer class instead of direct OpenGL
/// calls, which is more limited. To create a derived drawable class,
/// all you have to do is to override the virtual Render function.
///
/// One of the main benefits of creating your own drawable class is
/// that you can build hierarchies of drawable objects. Indeed,
/// when you draw a drawable inside the Render function of another
/// drawable, the former inherits the transformations and color of
/// the latter and combines them with its own attributes.
/// This way, you can apply global transformations/color to a set
/// of drawables as if it was a single entity.
///
/// Example:
/// \code
/// class MyDrawable : public sf::Drawable
/// {
/// public :
///
/// ...
///
/// private :
///
/// virtual void Render(sf::RenderTarget& target, sf::Renderer& renderer) const
/// {
/// // Low-level geometry rendering
/// renderer.SetTexture(&myTexture);
/// renderer.Begin(sf::Renderer::QuadList);
/// renderer.AddVertex(...);
/// renderer.AddVertex(...);
/// renderer.AddVertex(...);
/// renderer.AddVertex(...);
/// renderer.End();
///
/// // High-level drawable rendering
/// target.Draw(mySubSprite);
/// }
///
/// sf::Image myTexture;
/// sf::Sprite mySubSprite;
/// };
/// \endcode
///
/// \see sf::Shape, sf::Sprite, sf::Text
///
////////////////////////////////////////////////////////////

View File

@ -229,7 +229,7 @@ public :
/// ///
/// More specifically, it must be used around code that /// More specifically, it must be used around code that
/// calls Draw functions. Example: /// calls Draw functions. Example:
/// \begincode /// \code
/// // OpenGL code here... /// // OpenGL code here...
/// window.SaveGLStates(); /// window.SaveGLStates();
/// window.Draw(...); /// window.Draw(...);

View File

@ -241,7 +241,7 @@ public :
/// between Begin() and End(). /// between Begin() and End().
/// ///
/// Usage: /// Usage:
/// \begincode /// \code
/// renderer.Begin(Renderer::TriangleList); /// renderer.Begin(Renderer::TriangleList);
/// renderer.AddVertex(...); /// renderer.AddVertex(...);
/// renderer.AddVertex(...); /// renderer.AddVertex(...);

View File

@ -242,7 +242,7 @@ public :
/// ///
/// This is a static function that returns a new object, /// This is a static function that returns a new object,
/// don't try to call it on an existing object to modify it. /// don't try to call it on an existing object to modify it.
/// \begincode /// \code
/// sf::Shape line = sf::Shape::Line(0, 0, 10, 20, 2.5f, sf::Color::Green); /// sf::Shape line = sf::Shape::Line(0, 0, 10, 20, 2.5f, sf::Color::Green);
/// \endcode /// \endcode
/// ///
@ -265,7 +265,7 @@ public :
/// ///
/// This is a static function that returns a new object, /// This is a static function that returns a new object,
/// don't try to call it on an existing object to modify it. /// don't try to call it on an existing object to modify it.
/// \begincode /// \code
/// sf::Vector2f start(0, 0); /// sf::Vector2f start(0, 0);
/// sf::Vector2f end(10, 20); /// sf::Vector2f end(10, 20);
/// sf::Shape line = sf::Shape::Line(start, end, 2.5f, sf::Color::Green); /// sf::Shape line = sf::Shape::Line(start, end, 2.5f, sf::Color::Green);
@ -288,7 +288,7 @@ public :
/// ///
/// This is a static function that returns a new object, /// This is a static function that returns a new object,
/// don't try to call it on an existing object to modify it. /// don't try to call it on an existing object to modify it.
/// \begincode /// \code
/// sf::Shape rect = sf::Shape::Rectangle(10, 20, 50, 100, sf::Color::Red); /// sf::Shape rect = sf::Shape::Rectangle(10, 20, 50, 100, sf::Color::Red);
/// \endcode /// \endcode
/// ///
@ -310,7 +310,7 @@ public :
/// ///
/// This is a static function that returns a new object, /// This is a static function that returns a new object,
/// don't try to call it on an existing object to modify it. /// don't try to call it on an existing object to modify it.
/// \begincode /// \code
/// sf::FloatRect source(10, 20, 50, 100); /// sf::FloatRect source(10, 20, 50, 100);
/// sf::Shape rect = sf::Shape::Rectangle(source, sf::Color::Red); /// sf::Shape rect = sf::Shape::Rectangle(source, sf::Color::Red);
/// \endcode /// \endcode
@ -330,7 +330,7 @@ public :
/// ///
/// This is a static function that returns a new object, /// This is a static function that returns a new object,
/// don't try to call it on an existing object to modify it. /// don't try to call it on an existing object to modify it.
/// \begincode /// \code
/// sf::Shape circle = sf::Shape::Circle(0, 0, 7, sf::Color::Blue); /// sf::Shape circle = sf::Shape::Circle(0, 0, 7, sf::Color::Blue);
/// \endcode /// \endcode
/// ///
@ -351,7 +351,7 @@ public :
/// ///
/// This is a static function that returns a new object, /// This is a static function that returns a new object,
/// don't try to call it on an existing object to modify it. /// don't try to call it on an existing object to modify it.
/// \begincode /// \code
/// sf::Vector2f center(0, 0); /// sf::Vector2f center(0, 0);
/// sf::Shape circle = sf::Shape::Circle(center, 7, sf::Color::Blue); /// sf::Shape circle = sf::Shape::Circle(center, 7, sf::Color::Blue);
/// \endcode /// \endcode

View File

@ -239,3 +239,29 @@ private :
#endif // SFML_SPRITE_HPP #endif // SFML_SPRITE_HPP
////////////////////////////////////////////////////////////
/// \class sf::Sprite
///
/// ...
///
/// Usage example:
/// \code
/// // Declare and load an image
/// sf::Image image;
/// image.LoadFromFile("image.png");
///
/// // Create a sprite
/// sf::Sprite sprite;
/// text.SetImage(image);
/// text.SetSubRect(sf::IntRect(10, 10, 50, 30));
/// text.Resize(100, 60);
///
/// // Display it
/// window.Draw(sprite); // window is a sf::RenderWindow
/// \endcode
///
/// \see sf::Image
///
////////////////////////////////////////////////////////////

View File

@ -82,7 +82,7 @@ public :
/// The \a string argument is a sf::String, which can /// The \a string argument is a sf::String, which can
/// automatically be constructed from standard string types. /// automatically be constructed from standard string types.
/// So, the following calls are all valid: /// So, the following calls are all valid:
/// \begincode /// \code
/// text.SetString("hello"); /// text.SetString("hello");
/// text.SetString(L"hello"); /// text.SetString(L"hello");
/// text.SetString(std::string("hello")); /// text.SetString(std::string("hello"));
@ -142,7 +142,7 @@ public :
/// The returned string is a sf::String, which can automatically /// The returned string is a sf::String, which can automatically
/// be converted to standard string types. So, the following /// be converted to standard string types. So, the following
/// lines of code are all valid: /// lines of code are all valid:
/// \begincode /// \code
/// sf::String s1 = text.GetString(); /// sf::String s1 = text.GetString();
/// std::string s2 = text.GetString(); /// std::string s2 = text.GetString();
/// std::wstring s3 = text.GetString(); /// std::wstring s3 = text.GetString();
@ -250,3 +250,55 @@ private :
#endif // SFML_TEXT_HPP #endif // SFML_TEXT_HPP
////////////////////////////////////////////////////////////
/// \class sf::Text
///
/// sf::Text is a drawable class that allows to easily display
/// some text with custom style and color on a render target.
///
/// It inherits all the functions from sf::Drawable:
/// position, rotation, scale, origin, global color and blend
/// mode. It also adds text-specific properties such as the
/// font to use, the character size, the font style (bold,
/// italic, underlined), and the text to display of course.
/// It also provides convenience functions to calculate the
/// graphical size of the text, or to get the visual position
/// of a given character.
///
/// sf::Text works in combination with the sf::Font class, which
/// loads and provides the glyphs (visual characters) of a given font.
///
/// The separation of sf::Font and sf::Text 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.
///
/// 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 and load a font
/// sf::Font font;
/// font.LoadFromFile("arial.ttf");
///
/// // Create a text
/// sf::Text text("hello");
/// text.SetFont(font);
/// text.SetCharacterSize(30);
/// text.SetStyle(sf::Text::Regular);
///
/// // Display it
/// window.Draw(text); // window is a sf::RenderWindow
/// \endcode
///
/// \see sf::Font
///
////////////////////////////////////////////////////////////

View File

@ -137,7 +137,7 @@ public :
/// This behaviour is the same as standard C++ streams. /// This behaviour is the same as standard C++ streams.
/// ///
/// Usage example: /// Usage example:
/// \begincode /// \code
/// float x; /// float x;
/// packet >> x; /// packet >> x;
/// if (packet) /// if (packet)
@ -289,7 +289,7 @@ private :
/// and your data may be corrupted if that happens. /// and your data may be corrupted if that happens.
/// ///
/// Usage example: /// Usage example:
/// \begincode /// \code
/// sf::Uint32 x = 24; /// sf::Uint32 x = 24;
/// std::string s = "hello"; /// std::string s = "hello";
/// double d = 5.89; /// double d = 5.89;
@ -328,7 +328,7 @@ private :
/// overloads of operators >> and << in order to handle your /// overloads of operators >> and << in order to handle your
/// custom types. /// custom types.
/// ///
/// \begincode /// \code
/// struct MyStruct /// struct MyStruct
/// { /// {
/// float number; /// float number;
@ -355,7 +355,7 @@ private :
/// the OnSend and OnReceive functions. /// the OnSend and OnReceive functions.
/// ///
/// Here is an example: /// Here is an example:
/// \begincode /// \code
/// class ZipPacket : public sf::Packet /// class ZipPacket : public sf::Packet
/// { /// {
/// virtual const char* OnSend(std::size_t& size) /// virtual const char* OnSend(std::size_t& size)

View File

@ -6,6 +6,7 @@
#include <SFML/Network.hpp> #include <SFML/Network.hpp>
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
#include <iterator>
const sf::Uint8 audioData = 1; const sf::Uint8 audioData = 1;

View File

@ -34,8 +34,6 @@
namespace sf namespace sf
{ {
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// Default constructor
////////////////////////////////////////////////////////////
Drawable::Drawable(const Vector2f& position, const Vector2f& scale, float rotation, const Color& color) : Drawable::Drawable(const Vector2f& position, const Vector2f& scale, float rotation, const Color& color) :
myPosition (position), myPosition (position),
myScale (scale), myScale (scale),
@ -49,8 +47,6 @@ myInvMatrixUpdated(false)
} }
////////////////////////////////////////////////////////////
/// Virtual destructor
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Drawable::~Drawable() Drawable::~Drawable()
{ {
@ -58,8 +54,6 @@ Drawable::~Drawable()
} }
////////////////////////////////////////////////////////////
/// Set the position of the object (take 2 values)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Drawable::SetPosition(float x, float y) void Drawable::SetPosition(float x, float y)
{ {
@ -68,8 +62,6 @@ void Drawable::SetPosition(float x, float y)
} }
////////////////////////////////////////////////////////////
/// Set the position of the object (take a 2D vector)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Drawable::SetPosition(const Vector2f& position) void Drawable::SetPosition(const Vector2f& position)
{ {
@ -78,8 +70,6 @@ void Drawable::SetPosition(const Vector2f& position)
} }
////////////////////////////////////////////////////////////
/// Set the X position of the object
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Drawable::SetX(float x) void Drawable::SetX(float x)
{ {
@ -90,8 +80,6 @@ void Drawable::SetX(float x)
} }
////////////////////////////////////////////////////////////
/// Set the Y position of the object
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Drawable::SetY(float y) void Drawable::SetY(float y)
{ {
@ -102,8 +90,6 @@ void Drawable::SetY(float y)
} }
////////////////////////////////////////////////////////////
/// Set the scale of the object (take 2 values)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Drawable::SetScale(float factorX, float factorY) void Drawable::SetScale(float factorX, float factorY)
{ {
@ -112,8 +98,6 @@ void Drawable::SetScale(float factorX, float factorY)
} }
////////////////////////////////////////////////////////////
/// Set the scale of the object (take a 2D vector)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Drawable::SetScale(const Vector2f& scale) void Drawable::SetScale(const Vector2f& scale)
{ {
@ -122,8 +106,6 @@ void Drawable::SetScale(const Vector2f& scale)
} }
////////////////////////////////////////////////////////////
/// Set the X scale factor of the object
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Drawable::SetScaleX(float factor) void Drawable::SetScaleX(float factor)
{ {
@ -137,8 +119,6 @@ void Drawable::SetScaleX(float factor)
} }
////////////////////////////////////////////////////////////
/// Set the Y scale factor of the object
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Drawable::SetScaleY(float factor) void Drawable::SetScaleY(float factor)
{ {
@ -152,10 +132,6 @@ void Drawable::SetScaleY(float factor)
} }
////////////////////////////////////////////////////////////
/// Set the local origin of the object, in coordinates relative to the
/// top-left of the object (take 2 values).
/// The default origin is (0, 0)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Drawable::SetOrigin(float x, float y) void Drawable::SetOrigin(float x, float y)
{ {
@ -167,10 +143,6 @@ void Drawable::SetOrigin(float x, float y)
} }
////////////////////////////////////////////////////////////
/// Set the local origin of the object, in coordinates relative to the
/// top-left of the object (take a 2D vector).
/// The default origin is (0, 0)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Drawable::SetOrigin(const Vector2f& origin) void Drawable::SetOrigin(const Vector2f& origin)
{ {
@ -178,8 +150,6 @@ void Drawable::SetOrigin(const Vector2f& origin)
} }
////////////////////////////////////////////////////////////
/// Set the orientation of the object
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Drawable::SetRotation(float angle) void Drawable::SetRotation(float angle)
{ {
@ -192,9 +162,6 @@ void Drawable::SetRotation(float angle)
} }
////////////////////////////////////////////////////////////
/// Set the color of the object.
/// The default color is white
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Drawable::SetColor(const Color& color) void Drawable::SetColor(const Color& color)
{ {
@ -202,9 +169,6 @@ void Drawable::SetColor(const Color& color)
} }
////////////////////////////////////////////////////////////
/// Set the blending mode for the object.
/// The default blend mode is Blend::Alpha
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Drawable::SetBlendMode(Blend::Mode mode) void Drawable::SetBlendMode(Blend::Mode mode)
{ {
@ -212,8 +176,6 @@ void Drawable::SetBlendMode(Blend::Mode mode)
} }
////////////////////////////////////////////////////////////
/// Get the position of the object
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const Vector2f& Drawable::GetPosition() const const Vector2f& Drawable::GetPosition() const
{ {
@ -221,8 +183,6 @@ const Vector2f& Drawable::GetPosition() const
} }
////////////////////////////////////////////////////////////
/// Get the current scale of the object
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const Vector2f& Drawable::GetScale() const const Vector2f& Drawable::GetScale() const
{ {
@ -230,8 +190,6 @@ const Vector2f& Drawable::GetScale() const
} }
////////////////////////////////////////////////////////////
/// Get the origin of the object
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const Vector2f& Drawable::GetOrigin() const const Vector2f& Drawable::GetOrigin() const
{ {
@ -239,8 +197,6 @@ const Vector2f& Drawable::GetOrigin() const
} }
////////////////////////////////////////////////////////////
/// Get the orientation of the object
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
float Drawable::GetRotation() const float Drawable::GetRotation() const
{ {
@ -248,8 +204,6 @@ float Drawable::GetRotation() const
} }
////////////////////////////////////////////////////////////
/// Get the color of the object
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const Color& Drawable::GetColor() const const Color& Drawable::GetColor() const
{ {
@ -257,8 +211,6 @@ const Color& Drawable::GetColor() const
} }
////////////////////////////////////////////////////////////
/// Get the current blending mode
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Blend::Mode Drawable::GetBlendMode() const Blend::Mode Drawable::GetBlendMode() const
{ {
@ -266,9 +218,6 @@ Blend::Mode Drawable::GetBlendMode() const
} }
////////////////////////////////////////////////////////////
/// Move the object of a given offset (take 2 values)
///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Drawable::Move(float offsetX, float offsetY) void Drawable::Move(float offsetX, float offsetY)
{ {
@ -276,8 +225,6 @@ void Drawable::Move(float offsetX, float offsetY)
} }
////////////////////////////////////////////////////////////
/// Move the object of a given offset (take a 2D vector)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Drawable::Move(const Vector2f& offset) void Drawable::Move(const Vector2f& offset)
{ {
@ -285,8 +232,6 @@ void Drawable::Move(const Vector2f& offset)
} }
////////////////////////////////////////////////////////////
/// Scale the object (take 2 values)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Drawable::Scale(float factorX, float factorY) void Drawable::Scale(float factorX, float factorY)
{ {
@ -294,8 +239,6 @@ void Drawable::Scale(float factorX, float factorY)
} }
////////////////////////////////////////////////////////////
/// Scale the object (take a 2D vector)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Drawable::Scale(const Vector2f& factor) void Drawable::Scale(const Vector2f& factor)
{ {
@ -303,8 +246,6 @@ void Drawable::Scale(const Vector2f& factor)
} }
////////////////////////////////////////////////////////////
/// Rotate the object
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Drawable::Rotate(float angle) void Drawable::Rotate(float angle)
{ {
@ -312,18 +253,13 @@ void Drawable::Rotate(float angle)
} }
////////////////////////////////////////////////////////////
/// Transform a point from global coordinates into local coordinates
/// (ie it applies the inverse of object's origin, translation, rotation and scale to the point)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Vector2f Drawable::TransformToLocal(const Vector2f& point) const Vector2f Drawable::TransformToLocal(const Vector2f& point) const
{ {
return GetInverseMatrix().Transform(point); return GetInverseMatrix().Transform(point);
} }
////////////////////////////////////////////////////////////
/// Transform a point from local coordinates into global coordinates
/// (ie it applies the object's origin, translation, rotation and scale to the point)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Vector2f Drawable::TransformToGlobal(const Vector2f& point) const Vector2f Drawable::TransformToGlobal(const Vector2f& point) const
{ {
@ -331,8 +267,6 @@ Vector2f Drawable::TransformToGlobal(const Vector2f& point) const
} }
////////////////////////////////////////////////////////////
/// Get the transform matrix of the drawable
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const Matrix3& Drawable::GetMatrix() const const Matrix3& Drawable::GetMatrix() const
{ {
@ -347,8 +281,6 @@ const Matrix3& Drawable::GetMatrix() const
} }
////////////////////////////////////////////////////////////
/// Get the inverse transform matrix of the drawable
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
const Matrix3& Drawable::GetInverseMatrix() const const Matrix3& Drawable::GetInverseMatrix() const
{ {
@ -363,8 +295,6 @@ const Matrix3& Drawable::GetInverseMatrix() const
} }
////////////////////////////////////////////////////////////
/// Draw the object into the specified render target
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void Drawable::Draw(RenderTarget& target, Renderer& renderer) const void Drawable::Draw(RenderTarget& target, Renderer& renderer) const
{ {