| Drawable.hpp | | Drawable.hpp | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| // | | // | |
| // SFML - Simple and Fast Multimedia Library | | // SFML - Simple and Fast Multimedia Library | |
|
| // Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com) | | // Copyright (C) 2007-2008 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/Color.hpp> | | #include <SFML/Graphics/Color.hpp> | |
|
| | | #include <SFML/Graphics/Matrix3.hpp> | |
| | | | |
| namespace sf | | namespace sf | |
| { | | { | |
| class RenderWindow; | | class RenderWindow; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Enumerate the blending modes for drawable objects | | /// Enumerate the blending modes for drawable objects | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| namespace Blend | | namespace Blend | |
| { | | { | |
| | | | |
| skipping to change at line 62 | | skipping to change at line 64 | |
| /// Abstract base class for every object that can be drawn | | /// Abstract base class for every object that can be drawn | |
| /// into a render window | | /// into a render window | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| class SFML_API Drawable | | class SFML_API Drawable | |
| { | | { | |
| public : | | public : | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Default constructor | | /// Default constructor | |
| /// | | /// | |
|
| /// \param Left : Left coordinate of the object (0 by default) | | /// \param Position : Position of the object (0, 0 by default) | |
| /// \param Top : Top coordinate of the object (0 by default) | | /// \param Scale : Scale factor (1, 1 by default) | |
| /// \param ScaleX : Horizontal scale (1 by default) | | | |
| /// \param ScaleY : Vertical scale (1 by default) | | | |
| /// \param Rotation : Orientation, in degrees (0 by default) | | /// \param Rotation : Orientation, in degrees (0 by default) | |
| /// \param Col : Color of the object (white by default) | | /// \param Col : Color of the object (white by default) | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| Drawable(float Left = 0.f, float Top = 0.f, float ScaleX = 1.f, float S
caleY = 1.f, float Rotation = 0.f, const Color& Col = Color(255, 255, 255,
255)); | | 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 destructor | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| virtual ~Drawable(); | | virtual ~Drawable(); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Set the left position of the object | | /// Set the position of the object (take 2 values) | |
| /// | | /// | |
|
| /// \param Left : New left coordinate | | /// \param X : New X coordinate | |
| | | /// \param Y : New Y coordinate | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| void SetLeft(float Left); | | void SetPosition(float X, float Y); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Set the top position of the object | | /// Set the position of the object (take a 2D vector) | |
| /// | | /// | |
|
| /// \param Top : New top coordinate | | /// \param Position : New position | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| void SetTop(float Top); | | void SetPosition(const Vector2f& Position); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Set the position of the object | | /// Set the X position of the object | |
| /// | | /// | |
|
| /// \param Left : New left coordinate | | /// \param X : New X coordinate | |
| /// \param Top : New top coordinate | | | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| void SetPosition(float Left, float Top); | | void SetX(float X); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Set the horizontal scale of the object | | /// Set the Y position of the object | |
| /// | | /// | |
|
| /// \param Scale : New scale (must be strictly positive) | | /// \param Y : New Y coordinate | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| void SetScaleX(float Scale); | | void SetY(float Y); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Set the vertical scale of the object | | /// Set the scale of the object (take 2 values) | |
| /// | | /// | |
|
| /// \param Scale : New scale (must be strictly positive) | | /// \param ScaleX : New horizontal scale (must be strictly positive) | |
| | | /// \param ScaleY : New vertical scale (must be strictly positive) | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| void SetScaleY(float Scale); | | void SetScale(float ScaleX, float ScaleY); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Set the scale of the object | | /// Set the scale of the object (take a 2D vector) | |
| /// | | /// | |
|
| /// \param ScaleX : New horizontal scale (must be strictly positive) | | /// \param Scale : New scale (both values must be strictly positive) | |
| /// \param ScaleY : New vertical scale (must be strictly positive) | | | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| void SetScale(float ScaleX, float ScaleY); | | void SetScale(const Vector2f& Scale); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Set the orientation of the object | | /// Set the X scale factor of the object | |
| /// | | /// | |
|
| /// \param Rotation : Angle of rotation, in degrees | | /// \param X : New X scale factor | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| void SetRotation(float Rotation); | | 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 center of rotation, in coordinates relative to the | | /// Set the orientation of the object | |
| /// object. | | | |
| /// The default rotation center is (0, 0) | | | |
| /// | | /// | |
|
| /// \param X : X coordinate of the center of rotation | | /// \param Rotation : Angle of rotation, in degrees | |
| /// \param Y : Y coordinate of the center of rotation | | | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| void SetRotationCenter(float X, float Y); | | void SetRotation(float Rotation); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Set the color of the object. | | /// Set the color of the object. | |
| /// The default color is white | | /// The default color is white | |
| /// | | /// | |
| /// \param Col : New color | | /// \param Col : New color | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| void SetColor(const Color& Col); | | void SetColor(const Color& Col); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Set the blending mode for the object. | | /// Set the blending mode for the object. | |
| /// The default blend mode is Blend::Alpha | | /// The default blend mode is Blend::Alpha | |
| /// | | /// | |
| /// \param Mode : New blending mode | | /// \param Mode : New blending mode | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| void SetBlendMode(Blend::Mode Mode); | | void SetBlendMode(Blend::Mode Mode); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Get the left position of the object | | /// Get the position of the object | |
| /// | | | |
| /// \return Current left position | | | |
| /// | | | |
| //////////////////////////////////////////////////////////// | | | |
| float GetLeft() const; | | | |
| | | | |
| //////////////////////////////////////////////////////////// | | | |
| /// Get the top position of the object | | | |
| /// | | /// | |
|
| /// \return Current top position | | /// \return Current position | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| float GetTop() const; | | const Vector2f& GetPosition() const; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Get the horizontal scale of the object | | /// Get the current scale of the object | |
| /// | | /// | |
|
| /// \return Current X scale factor (always positive) | | /// \return Current scale factor (always positive) | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| float GetScaleX() const; | | const Vector2f& GetScale() const; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Get the vertical scale of the object | | /// Get the center of the object | |
| /// | | /// | |
|
| /// \return Current Y scale factor (always positive) | | /// \return Current position of the center | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| float GetScaleY() const; | | const Vector2f& GetCenter() const; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Get the orientation of the object | | /// Get the orientation of the object. | |
| | | /// Rotation is always in the range [0, 360] | |
| /// | | /// | |
| /// \return Current rotation, in degrees | | /// \return Current rotation, in degrees | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| float GetRotation() const; | | float GetRotation() const; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Get the color of the object | | /// Get the color of the object | |
| /// | | /// | |
| /// \return Current color | | /// \return Current color | |
| | | | |
| skipping to change at line 222 | | skipping to change at line 241 | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Get the current blending mode | | /// Get the current blending mode | |
| /// | | /// | |
| /// \return Current blending mode | | /// \return Current blending mode | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| Blend::Mode GetBlendMode() const; | | Blend::Mode GetBlendMode() const; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Move the object | | /// Move the object of a given offset (take 2 values) | |
| /// | | /// | |
|
| /// \param OffsetX : Offset on the X axis | | /// \param OffsetX : X offset | |
| /// \param OffsetY : Offset on the Y axis | | /// \param OffsetY : Y offset | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| void Move(float OffsetX, float OffsetY); | | void Move(float OffsetX, float OffsetY); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Scale the object | | /// 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 : Horizontal scaling factor (must be strictly positi | | /// \param FactorX : Scaling factor on X (must be strictly positive) | |
| ve) | | /// \param FactorY : Scaling factor on Y (must be strictly positive) | |
| /// \param FactorY : Vertical scaling factor (must be strictly positive | | | |
| ) | | | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| void Scale(float FactorX, float FactorY); | | 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 | | /// Rotate the object | |
| /// | | /// | |
| /// \param Angle : Angle of rotation, in degrees | | /// \param Angle : Angle of rotation, in degrees | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| void Rotate(float Angle); | | void Rotate(float Angle); | |
| | | | |
|
| | | protected : | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Get the transform matrix of the drawable | |
| | | /// | |
| | | /// \return Transform matrix | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | const Matrix3& GetMatrix() const; | |
| | | | |
| private : | | private : | |
| | | | |
| friend class RenderWindow; | | friend class RenderWindow; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Draw the object into the specified window | | /// Draw the object into the specified window | |
| /// | | /// | |
| /// \param Window : Window into which draw the object | | /// \param Window : Window into which draw the object | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| | | | |
| skipping to change at line 270 | | skipping to change at line 315 | |
| /// Render the specific geometry of the object | | /// Render the specific geometry of the object | |
| /// | | /// | |
| /// \param Window : Window into which render the object | | /// \param Window : Window into which render the object | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| virtual void Render(const RenderWindow& Window) const = 0; | | virtual void Render(const RenderWindow& Window) const = 0; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| // Member data | | // Member data | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| float myLeft; ///< Left position of the object on screen | | Vector2f myPosition; ///< Position of the object on screen | |
| float myTop; ///< Top position of the object on screen | | Vector2f myScale; ///< Scale of the object | |
| float myScaleX; ///< Horizontal scale of the object | | Vector2f myCenter; ///< Origin of translation / rotation / s | |
| float myScaleY; ///< Vertical scale of the object | | caling of the object | |
| float myRotation; ///< Orientation of the object, in degrees | | float myRotation; ///< Orientation of the object, in degree | |
| float myCenterX; ///< X coordinate of the center of rotation, r | | s | |
| elative to the object | | Color myColor; ///< Overlay color of the object | |
| float myCenterY; ///< Y coordinate of the center of rotation, r | | Blend::Mode myBlendMode; ///< Blending mode | |
| elative to the object | | mutable bool myNeedUpdate; ///< Do we need to recompute the transfor | |
| Color myColor; ///< Overlay color of the object | | m matrix ? | |
| Blend::Mode myBlendMode; ///< Blending mode | | mutable Matrix3 myMatrix; ///< Precomputed transform matrix gatheri | |
| | | ng the translation / rotation / scale / center | |
| }; | | }; | |
| | | | |
| } // namespace sf | | } // namespace sf | |
| | | | |
| #endif // SFML_DRAWABLE_HPP | | #endif // SFML_DRAWABLE_HPP | |
| | | | |
End of changes. 46 change blocks. |
| 72 lines changed or deleted | | 117 lines changed or added | |
|
| Event.hpp | | Event.hpp | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| // | | // | |
| // SFML - Simple and Fast Multimedia Library | | // SFML - Simple and Fast Multimedia Library | |
|
| // Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com) | | // Copyright (C) 2007-2008 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 | |
| | | | |
| namespace sf | | namespace sf | |
| { | | { | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Definition of key codes for keyboard events | | /// Definition of key codes for keyboard events | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| namespace Key | | namespace Key | |
| { | | { | |
| enum Code | | enum Code | |
| { | | { | |
|
| A = 'a', Z = 'z', E = 'e', R = 'r', T = 't', Y = 'y', U = 'u', I = | | A = 'a', | |
| 'i', O = 'o', P = 'p', | | B = 'b', | |
| Q = 'q', S = 's', D = 'd', F = 'f', G = 'g', H = 'h', J = 'j', K = | | C = 'c', | |
| 'k', L = 'l', M = 'm', | | D = 'd', | |
| W = 'w', X = 'x', C = 'c', V = 'v', B = 'b', N = 'n', | | E = 'e', | |
| Num0 = '0', Num1 = '1', Num2 = '2', Num3 = '3', Num4 = '4', | | F = 'f', | |
| Num5 = '5', Num6 = '6', Num7 = '7', Num8 = '8', Num9 = '9', | | 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, | | Escape = 256, | |
|
| Control, Shift, Alt, | | LControl, | |
| Space, Return, Back, Tab, PageUp, PageDown, End, Home, Insert, Dele | | LShift, | |
| te, Add, Subtract, Multiply, Divide, | | LAlt, | |
| Left, Right, Up, Down, | | LSystem, ///< OS specific key (left side) : windows (Win and L | |
| Numpad0, Numpad1, Numpad2, Numpad3, Numpad4, Numpad5, Numpad6, Nump | | inux), apple (MacOS), ... | |
| ad7, Numpad8, Numpad9, | | RControl, | |
| F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, | | 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, | | Pause, | |
| | | | |
| Count // For internal use | | Count // For internal use | |
| }; | | }; | |
| } | | } | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Definition of button codes for mouse events | | /// Definition of button codes for mouse events | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| namespace Mouse | | namespace Mouse | |
| | | | |
| skipping to change at line 103 | | skipping to change at line 192 | |
| } | | } | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Event defines a system event and its parameters | | /// Event defines a system event and its parameters | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| class Event | | class Event | |
| { | | { | |
| public : | | public : | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| | | /// Keyboard event parameters | |
| | | //////////////////////////////////////////////////////////// | |
| | | struct KeyEvent | |
| | | { | |
| | | Key::Code Code; | |
| | | bool Alt; | |
| | | bool Control; | |
| | | bool Shift; | |
| | | }; | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Text event parameters | |
| | | //////////////////////////////////////////////////////////// | |
| | | struct TextEvent | |
| | | { | |
| | | Uint16 Unicode; | |
| | | }; | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Mouse move event parameters | |
| | | //////////////////////////////////////////////////////////// | |
| | | struct MouseMoveEvent | |
| | | { | |
| | | unsigned int X; | |
| | | unsigned int Y; | |
| | | }; | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Mouse buttons events parameters | |
| | | //////////////////////////////////////////////////////////// | |
| | | struct MouseButtonEvent | |
| | | { | |
| | | Mouse::Button Button; | |
| | | }; | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Mouse wheel events parameters | |
| | | //////////////////////////////////////////////////////////// | |
| | | struct MouseWheelEvent | |
| | | { | |
| | | int Delta; | |
| | | }; | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Joystick axis move event parameters | |
| | | //////////////////////////////////////////////////////////// | |
| | | struct JoyMoveEvent | |
| | | { | |
| | | unsigned int JoystickId; | |
| | | Joy::Axis Axis; | |
| | | float Position; | |
| | | }; | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Joystick buttons events parameters | |
| | | //////////////////////////////////////////////////////////// | |
| | | struct JoyButtonEvent | |
| | | { | |
| | | unsigned int JoystickId; | |
| | | unsigned int Button; | |
| | | }; | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Size events parameters | |
| | | //////////////////////////////////////////////////////////// | |
| | | struct SizeEvent | |
| | | { | |
| | | unsigned int Width; | |
| | | unsigned int Height; | |
| | | }; | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| /// Enumeration of the different types of events | | /// Enumeration of the different types of events | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| enum EventType | | enum EventType | |
| { | | { | |
| Closed, | | Closed, | |
| Resized, | | Resized, | |
| LostFocus, | | LostFocus, | |
| GainedFocus, | | GainedFocus, | |
| TextEntered, | | TextEntered, | |
| KeyPressed, | | KeyPressed, | |
| | | | |
| skipping to change at line 130 | | skipping to change at line 291 | |
| JoyMoved | | JoyMoved | |
| }; | | }; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| // Member data | | // Member data | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| EventType Type; ///< Type of the event | | EventType Type; ///< Type of the event | |
| | | | |
| union | | union | |
| { | | { | |
|
| //////////////////////////////////////////////////////////// | | KeyEvent Key; | |
| /// Text event parameters | | TextEvent Text; | |
| //////////////////////////////////////////////////////////// | | MouseMoveEvent MouseMove; | |
| struct | | MouseButtonEvent MouseButton; | |
| { | | MouseWheelEvent MouseWheel; | |
| Uint16 Unicode; | | JoyMoveEvent JoyMove; | |
| } Text; | | JoyButtonEvent JoyButton; | |
| | | SizeEvent Size; | |
| //////////////////////////////////////////////////////////// | | | |
| /// Keyboard events parameters | | | |
| //////////////////////////////////////////////////////////// | | | |
| struct | | | |
| { | | | |
| Key::Code Code; | | | |
| bool Alt; | | | |
| bool Control; | | | |
| bool Shift; | | | |
| } Key; | | | |
| | | | |
| //////////////////////////////////////////////////////////// | | | |
| /// Mouse move event parameters | | | |
| //////////////////////////////////////////////////////////// | | | |
| struct | | | |
| { | | | |
| unsigned int X; | | | |
| unsigned int Y; | | | |
| } MouseMove; | | | |
| | | | |
| //////////////////////////////////////////////////////////// | | | |
| /// Mouse buttons events parameters | | | |
| //////////////////////////////////////////////////////////// | | | |
| struct | | | |
| { | | | |
| Mouse::Button Button; | | | |
| } MouseButton; | | | |
| | | | |
| //////////////////////////////////////////////////////////// | | | |
| /// Mouse wheel events parameters | | | |
| //////////////////////////////////////////////////////////// | | | |
| struct | | | |
| { | | | |
| int Delta; | | | |
| } MouseWheel; | | | |
| | | | |
| //////////////////////////////////////////////////////////// | | | |
| /// Joystick axis move event parameters | | | |
| //////////////////////////////////////////////////////////// | | | |
| struct | | | |
| { | | | |
| unsigned int JoystickId; | | | |
| Joy::Axis Axis; | | | |
| float Position; | | | |
| } JoyMove; | | | |
| | | | |
| //////////////////////////////////////////////////////////// | | | |
| /// Joystick buttons events parameters | | | |
| //////////////////////////////////////////////////////////// | | | |
| struct | | | |
| { | | | |
| unsigned int JoystickId; | | | |
| unsigned int Button; | | | |
| } JoyButton; | | | |
| | | | |
| //////////////////////////////////////////////////////////// | | | |
| /// Size events parameters | | | |
| //////////////////////////////////////////////////////////// | | | |
| struct | | | |
| { | | | |
| unsigned int Width; | | | |
| unsigned int Height; | | | |
| } Size; | | | |
| }; | | }; | |
| }; | | }; | |
| | | | |
| } // namespace sf | | } // namespace sf | |
| | | | |
| #endif // SFML_EVENT_HPP | | #endif // SFML_EVENT_HPP | |
| | | | |
End of changes. 5 change blocks. |
| 86 lines changed or deleted | | 182 lines changed or added | |
|
| Image.hpp | | Image.hpp | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| // | | // | |
| // SFML - Simple and Fast Multimedia Library | | // SFML - Simple and Fast Multimedia Library | |
|
| // Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com) | | // Copyright (C) 2007-2008 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 88 | | skipping to change at line 88 | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| Image(unsigned int Width, unsigned int Height, const Uint8* Data); | | Image(unsigned int Width, unsigned int Height, const Uint8* Data); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Destructor | | /// Destructor | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| ~Image(); | | ~Image(); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Load the surface from a file | | /// 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 | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| bool LoadFromFile(const std::string& Filename); | | bool LoadFromFile(const std::string& Filename); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Load the surface from a file in memory | | /// Load the image from a file in memory | |
| /// | | /// | |
| /// \param Data : Pointer to the file data in memory | | /// \param Data : Pointer to the file data in memory | |
| /// \param SizeInBytes : Size of the data to load, in bytes | | /// \param SizeInBytes : Size of the data to load, in bytes | |
| /// | | /// | |
| /// \return True if loading was successful | | /// \return True if loading was successful | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| bool LoadFromMemory(const char* Data, std::size_t SizeInBytes); | | bool LoadFromMemory(const char* Data, std::size_t SizeInBytes); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| | | | |
| skipping to change at line 140 | | skipping to change at line 140 | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Create an empty image | | /// Create an empty image | |
| /// | | /// | |
| /// \param Width : Image width | | /// \param Width : Image width | |
| /// \param Height : Image height | | /// \param Height : Image height | |
| /// \param Col : Image color (black by default) | | /// \param Col : Image color (black by default) | |
| /// | | /// | |
| /// \return True if creation was successful | | /// \return True if creation was successful | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| bool Create(unsigned int Width, unsigned int Height, const Color& Col =
Color(0, 0, 0, 255)); | | bool Create(unsigned int Width, unsigned int Height, Color Col = Color(
0, 0, 0, 255)); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Create transparency mask from a specified colorkey | | /// Create transparency mask from a specified colorkey | |
| /// | | /// | |
| /// \param ColorKey : Color to become transparent | | /// \param ColorKey : Color to become transparent | |
| /// \param Alpha : Alpha value to use for transparent pixels (0 by d
efault) | | /// \param Alpha : Alpha value to use for transparent pixels (0 by d
efault) | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| void CreateMaskFromColor(const Color& ColorKey, Uint8 Alpha = 0); | | void CreateMaskFromColor(Color ColorKey, Uint8 Alpha = 0); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Resize the image - warning : this function does not scale the image
, | | /// Resize the image - warning : this function does not scale the image
, | |
|
| /// it just ajdusts size (add padding or remove pixels) | | /// it just adjusts its size (add padding or remove pixels) | |
| /// | | /// | |
| /// \param Width : New width | | /// \param Width : New width | |
| /// \param Height : New height | | /// \param Height : New height | |
| /// \param Col : Color to assign to new pixels (black by default) | | /// \param Col : Color to assign to new pixels (black by default) | |
| /// | | /// | |
| /// \return True if resize has been successful | | /// \return True if resize has been successful | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| bool Resize(unsigned int Width, unsigned int Height, const Color& Col =
Color(0, 0, 0, 255)); | | bool Resize(unsigned int Width, unsigned int Height, Color Col = Color(
0, 0, 0, 255)); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Change the color of a pixel | | /// Change the color of a pixel | |
|
| /// Don't forget to call Update when you end modifying pixels | | | |
| /// | | /// | |
| /// \param X : X coordinate of pixel in the image | | /// \param X : X coordinate of pixel in the image | |
| /// \param Y : Y coordinate of pixel in the image | | /// \param Y : Y coordinate of pixel in the image | |
| /// \param Col : New color for pixel (X, Y) | | /// \param Col : New color for pixel (X, Y) | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| void SetPixel(unsigned int X, unsigned int Y, const Color& Col); | | void SetPixel(unsigned int X, unsigned int Y, const Color& Col); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Get a pixel from the image | | /// Get a pixel from the image | |
| /// | | /// | |
| /// \param X : X coordinate of pixel in the image | | /// \param X : X coordinate of pixel in the image | |
| /// \param Y : Y coordinate of pixel in the image | | /// \param Y : Y coordinate of pixel in the image | |
| /// | | /// | |
| /// \return Color of pixel (x, y) | | /// \return Color of pixel (x, y) | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| const Color& GetPixel(unsigned int X, unsigned int Y) const; | | const Color& GetPixel(unsigned int X, unsigned int Y) const; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Get a read-only pointer to the array of pixels (8 bits integers RGB
A) | | /// Get a read-only pointer to the array of pixels (RGBA 8 bits integer
s components) | |
| /// Array size is GetWidth() x GetHeight() x 4 | | /// Array size is GetWidth() x GetHeight() x 4 | |
| /// This pointer becomes invalid if you reload or resize the image | | /// This pointer becomes invalid if you reload or resize the image | |
| /// | | /// | |
| /// \return Const pointer to the array of pixels | | /// \return Const pointer to the array of pixels | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| const Uint8* GetPixelsPtr() const; | | const Uint8* GetPixelsPtr() const; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Bind the image for rendering | | /// Bind the image for rendering | |
| | | | |
| skipping to change at line 209 | | skipping to change at line 208 | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| void Bind() const; | | void Bind() const; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Enable or disable image smooth filter. | | /// Enable or disable image smooth filter. | |
| /// This parameter is enabled by default | | /// This parameter is enabled by default | |
| /// | | /// | |
| /// \param Smooth : True to enable smoothing filter, false to disable i
t | | /// \param Smooth : True to enable smoothing filter, false to disable i
t | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| void SetSmooth(bool Smooth) const; | | void SetSmooth(bool Smooth); | |
| | | | |
| //////////////////////////////////////////////////////////// | | | |
| /// Enable or disable image repeat mode | | | |
| /// (ie. how to define pixels outside the texture range). | | | |
| /// This parameter is enabled by default | | | |
| /// | | | |
| /// \param Repeat : True to enable repeat, false to disable | | | |
| /// | | | |
| //////////////////////////////////////////////////////////// | | | |
| void SetRepeat(bool Repeat) const; | | | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Return the width of the image | | /// Return the width of the image | |
| /// | | /// | |
| /// \return Width in pixels | | /// \return Width in pixels | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| unsigned int GetWidth() const; | | unsigned int GetWidth() const; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Return the height of the image | | /// Return the height of the image | |
| /// | | /// | |
| /// \return Height in pixels | | /// \return Height in pixels | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| unsigned int GetHeight() const; | | unsigned int GetHeight() const; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| | | /// Tells whether the smooth filtering is enabled or not | |
| | | /// | |
| | | /// \return True if image smoothing is enabled | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | bool IsSmooth() const; | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| /// Convert a subrect expressed in pixels, into float | | /// Convert a subrect expressed in pixels, into float | |
| /// texture coordinates | | /// texture coordinates | |
| /// | | /// | |
| /// \param Rect : Sub-rectangle of image to convert | | /// \param Rect : Sub-rectangle of image to convert | |
| /// \param Adjust : Pass true to apply the half-texel adjustment | | /// \param Adjust : Pass true to apply the half-texel adjustment | |
| /// | | /// | |
| /// \return Texture coordinates corresponding to the sub-rectangle | | /// \return Texture coordinates corresponding to the sub-rectangle | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| FloatRect GetTexCoords(const IntRect& Rect, bool Adjust = true) const; | | FloatRect GetTexCoords(const IntRect& Rect, bool Adjust = true) const; | |
| | | | |
| skipping to change at line 283 | | skipping to change at line 280 | |
| /// | | /// | |
| /// \return True if texture has been successfully created | | /// \return True if texture has been successfully created | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| bool CreateTexture(); | | bool CreateTexture(); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Update the internal texture in video memory | | /// Update the internal texture in video memory | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| void Update() const; | | void Update(); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Reset the image attributes | | /// Reset the image attributes | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| void Reset(); | | void Reset(); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// /see sfVideoResource::DestroyVideoResources | | /// /see VideoResource::DestroyVideoResources | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| virtual void DestroyVideoResources(); | | virtual void DestroyVideoResources(); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| // Member data | | // Member data | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| unsigned int myWidth; ///< Image width | | unsigned int myWidth; ///< Image width | |
| unsigned int myHeight; ///< Image Height | | unsigned int myHeight; ///< Image Height | |
| unsigned int myTextureWidth; ///< Actual texture width (can be g
reater than image width because of padding) | | unsigned int myTextureWidth; ///< Actual texture width (can be g
reater than image width because of padding) | |
| unsigned int myTextureHeight; ///< Actual texture height (can be
greater than image height because of padding) | | unsigned int myTextureHeight; ///< Actual texture height (can be
greater than image height because of padding) | |
| std::vector<Color> myPixels; ///< Pixels of the image | | std::vector<Color> myPixels; ///< Pixels of the image | |
|
| unsigned int myGLTexture; ///< OpenGL texture identifier | | unsigned int myTexture; ///< Internal texture identifier | |
| | | bool myIsSmooth; ///< Status if the smooth filter | |
| mutable bool myUpdated; ///< Tells if the internal texture
needs to be updated | | mutable bool myUpdated; ///< Tells if the internal texture
needs to be updated | |
| }; | | }; | |
| | | | |
| } // namespace sf | | } // namespace sf | |
| | | | |
| #endif // SFML_IMAGE_HPP | | #endif // SFML_IMAGE_HPP | |
| | | | |
End of changes. 14 change blocks. |
| 23 lines changed or deleted | | 21 lines changed or added | |
|
| Listener.hpp | | Listener.hpp | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| // | | // | |
| // SFML - Simple and Fast Multimedia Library | | // SFML - Simple and Fast Multimedia Library | |
|
| // Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com) | | // Copyright (C) 2007-2008 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_LISTENER_HPP | | #ifndef SFML_LISTENER_HPP | |
| #define SFML_LISTENER_HPP | | #define SFML_LISTENER_HPP | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| // Headers | | // Headers | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| #include <SFML/Config.hpp> | | #include <SFML/Config.hpp> | |
|
| | | #include <SFML/System/Vector3.hpp> | |
| | | | |
| namespace sf | | namespace sf | |
| { | | { | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Listener is a global interface for defining the audio | | /// Listener is a global interface for defining the audio | |
| /// listener properties ; the audio listener is the point in | | /// listener properties ; the audio listener is the point in | |
| /// the scene from where all the sounds are heard | | /// the scene from where all the sounds are heard | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| class SFML_API Listener | | class SFML_API Listener | |
| { | | { | |
| | | | |
| skipping to change at line 62 | | skipping to change at line 63 | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Get the current value of the global volume of all the sounds | | /// Get the current value of the global volume of all the sounds | |
| /// | | /// | |
| /// \return Current global volume, in the range [0, 100] | | /// \return Current global volume, in the range [0, 100] | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| static float GetGlobalVolume(); | | static float GetGlobalVolume(); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Change the position of the listener. | | /// Change the position of the listener (take 3 values). | |
| /// The default position is (0, 0, 0) | | /// The default position is (0, 0, 0) | |
| /// | | /// | |
|
| /// \param PosX : X position of the listener in the world | | /// \param X, Y, Z : Position of the listener in the world | |
| /// \param PosY : Y position of the listener in the world | | | |
| /// \param PosZ : Z position of the listener in the world | | | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| static void SetPosition(float PosX, float PosY, float PosZ); | | static void SetPosition(float X, float Y, float Z); | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Change the position of the listener (take a 3D vector). | |
| | | /// The default position is (0, 0, 0) | |
| | | /// | |
| | | /// \param Position : Position of the listener in the world | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | static void SetPosition(const Vector3f& Position); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Get the current position of the listener | | /// Get the current position of the listener | |
| /// | | /// | |
|
| /// \param PosX : X position of the listener in the world | | /// \return Position of the listener in the world | |
| /// \param PosY : Y position of the listener in the world | | /// | |
| /// \param PosZ : Z position of the listener in the world | | //////////////////////////////////////////////////////////// | |
| | | static Vector3f GetPosition(); | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Change the orientation of the listener (the point | |
| | | /// 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 | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| static void GetPosition(float& PosX, float& PosY, float& PosZ); | | static void SetTarget(float X, float Y, float Z); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Change the orientation of the listener (the point | | /// Change the orientation of the listener (the point | |
|
| /// he must look at). | | /// he must look at) (take a 3D vector). | |
| /// The default target is (0, 0, -1) | | /// The default target is (0, 0, -1) | |
| /// | | /// | |
|
| /// \param TargetX : X position of the point the listener must look at | | /// \param Target : Position of the point the listener must look at | |
| /// \param TargetY : X position of the point the listener must look at | | | |
| /// \param TargetZ : X position of the point the listener must look at | | | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| static void SetTarget(float TargetX, float TargetY, float TargetZ); | | static void SetTarget(const Vector3f& Target); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Get the current orientation of the listener (the point | | /// Get the current orientation of the listener (the point | |
| /// he's looking at) | | /// he's looking at) | |
| /// | | /// | |
|
| /// \param TargetX : X position of the point the listener is looking at | | /// \return : Position of the point the listener is looking at | |
| /// \param TargetY : X position of the point the listener is looking at | | | |
| /// \param TargetZ : X position of the point the listener is looking at | | | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| static void GetTarget(float& TargetX, float& TargetY, float& TargetZ); | | static Vector3f GetTarget(); | |
| }; | | }; | |
| | | | |
| } // namespace sf | | } // namespace sf | |
| | | | |
| #endif // SFML_LISTENER_HPP | | #endif // SFML_LISTENER_HPP | |
| | | | |
End of changes. 12 change blocks. |
| 19 lines changed or deleted | | 31 lines changed or added | |
|
| Packet.hpp | | Packet.hpp | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| // | | // | |
| // SFML - Simple and Fast Multimedia Library | | // SFML - Simple and Fast Multimedia Library | |
|
| // Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com) | | // Copyright (C) 2007-2008 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 101 | | skipping to change at line 101 | |
| /// | | /// | |
| /// \return True if data can be extracted from the packet | | /// \return True if data can be extracted from the packet | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| operator bool() const; | | operator bool() const; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Operator >> overloads to extract data from the packet | | /// Operator >> overloads to extract data from the packet | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| Packet& operator >>(Int8& Data); | | Packet& operator >>(Int8& Data); | |
| Packet& operator >>(Uint8& Data); | | Packet& operator >>(Uint8& Data); | |
| Packet& operator >>(Int16& Data); | | Packet& operator >>(Int16& Data); | |
| Packet& operator >>(Uint16& Data); | | Packet& operator >>(Uint16& Data); | |
| Packet& operator >>(Int32& Data); | | Packet& operator >>(Int32& Data); | |
| Packet& operator >>(Uint32& Data); | | Packet& operator >>(Uint32& Data); | |
| Packet& operator >>(float& Data); | | Packet& operator >>(float& Data); | |
| Packet& operator >>(double& Data); | | Packet& operator >>(double& Data); | |
| Packet& operator >>(char* Data); | | Packet& operator >>(char* Data); | |
| Packet& operator >>(std::string& Data); | | Packet& operator >>(std::string& Data); | |
| | | Packet& operator >>(wchar_t* Data); | |
| | | Packet& operator >>(std::wstring& Data); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Operator << overloads to put data into the packet | | /// Operator << overloads to put data into the packet | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| Packet& operator <<(Int8 Data); | | Packet& operator <<(Int8 Data); | |
| Packet& operator <<(Uint8 Data); | | Packet& operator <<(Uint8 Data); | |
| Packet& operator <<(Int16 Data); | | Packet& operator <<(Int16 Data); | |
| Packet& operator <<(Uint16 Data); | | Packet& operator <<(Uint16 Data); | |
| Packet& operator <<(Int32 Data); | | Packet& operator <<(Int32 Data); | |
| Packet& operator <<(Uint32 Data); | | Packet& operator <<(Uint32 Data); | |
| Packet& operator <<(float Data); | | Packet& operator <<(float Data); | |
| Packet& operator <<(double Data); | | Packet& operator <<(double Data); | |
| Packet& operator <<(const char* Data); | | Packet& operator <<(const char* Data); | |
| Packet& operator <<(const std::string& Data); | | Packet& operator <<(const std::string& Data); | |
| | | Packet& operator <<(const wchar_t* Data); | |
| | | Packet& operator <<(const std::wstring& Data); | |
| | | | |
| private : | | private : | |
| | | | |
| friend class SocketTCP; | | friend class SocketTCP; | |
| friend class SocketUDP; | | friend class SocketUDP; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Check if the packet can extract a given size of bytes | | /// Check if the packet can extract a given size of bytes | |
| /// | | /// | |
| /// \param Size : Size to check | | /// \param Size : Size to check | |
| | | | |
End of changes. 3 change blocks. |
| 21 lines changed or deleted | | 25 lines changed or added | |
|
| RenderWindow.hpp | | RenderWindow.hpp | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| // | | // | |
| // SFML - Simple and Fast Multimedia Library | | // SFML - Simple and Fast Multimedia Library | |
|
| // Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com) | | // Copyright (C) 2007-2008 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 59 | | skipping to change at line 59 | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Default constructor | | /// Default constructor | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| RenderWindow(); | | RenderWindow(); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Construct the window | | /// Construct the window | |
| /// | | /// | |
|
| /// \param Mode : Video mode to use | | /// \param Mode : Video mode to use | |
| /// \param Title : Title of the window | | /// \param Title : Title of the window | |
| /// \param WindowStyle : Window style (Resize | Close by default) | | /// \param WindowStyle : Window style (Resize | Close by default) | |
| /// \param AntialiasingLevel : Level of antialiasing (0 by default, dis | | /// \param Params : Creation parameters (see default constructor f | |
| abled) | | or default values) | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| RenderWindow(VideoMode Mode, const std::string& Title, unsigned long Wi
ndowStyle = Style::Resize | Style::Close, int AntialiasingLevel = 0); | | RenderWindow(VideoMode Mode, const std::string& Title, unsigned long Wi
ndowStyle = Style::Resize | Style::Close, const WindowSettings& Params = Wi
ndowSettings()); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Construct the window from an existing control | | /// Construct the window from an existing control | |
| /// | | /// | |
|
| /// \param Handle : Platform-specific handle of the control | | /// \param Handle : Platform-specific handle of the control | |
| /// \param AntialiasingLevel : Level of antialiasing (0 by default, dis | | /// \param Params : Creation parameters (see default constructor for de | |
| abled) | | fault values) | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| RenderWindow(WindowHandle Handle, int AntialiasingLevel = 0); | | RenderWindow(WindowHandle Handle, const WindowSettings& Params = Window
Settings()); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Destructor | | /// Destructor | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| virtual ~RenderWindow(); | | virtual ~RenderWindow(); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Draw something on the window | | /// Draw something on the window | |
| /// | | /// | |
| | | | |
| skipping to change at line 109 | | skipping to change at line 109 | |
| /// Change the background color of the window. | | /// Change the background color of the window. | |
| /// The default color is black | | /// The default color is black | |
| /// | | /// | |
| /// \param Col : New background color | | /// \param Col : New background color | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| void SetBackgroundColor(const Color& Col); | | void SetBackgroundColor(const Color& Col); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Change the current active view. | | /// Change the current active view. | |
|
| /// The current view is defined with the initial size of the window | | | |
| /// | | /// | |
|
| /// \param NewView : Pointer to the new view (pass NULL to set the defa
ult view) | | /// \param NewView : New view to use (pass GetDefaultView() to set the
default view) | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| void SetView(const View* NewView); | | void SetView(const View& NewView); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Get the current view rectangle | | /// Get the current view | |
| /// | | /// | |
|
| /// \return Current view rectangle, in global coordinates | | /// \return Current view active in the window | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| const FloatRect& GetViewRect() const; | | const View& GetView() const; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Tell SFML to optimize its calls to the graphics driver, | | /// Get the default view of the window for read / write | |
| /// in case the user is not doing custom OpenGL calls. | | /// | |
| | | /// \return Default view | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | View& GetDefaultView(); | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Convert a point in window coordinates into view coordinates | |
| | | /// | |
| | | /// \param WindowX : X coordinate of the point to convert, relative | |
| | | to the window | |
| | | /// \param WindowY : Y coordinate of the point to convert, relative | |
| | | to the window | |
| | | /// \param TargetView : Target view to convert the point to (NULL by de | |
| | | fault -- uses the current view) | |
| | | /// | |
| | | /// \return Converted point | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | sf::Vector2f ConvertCoords(unsigned int WindowX, unsigned int WindowY, | |
| | | const View* TargetView = NULL) const; | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Tell SFML to preserve external OpenGL states, at the expense of | |
| | | /// more CPU charge. Use this function if you don't want SFML | |
| | | /// to mess up your own OpenGL states (if any). | |
| | | /// Don't enable state preservation if not needed, as it will allow | |
| | | /// SFML to do internal optimizations and improve performances. | |
| /// This parameter is false by default | | /// This parameter is false by default | |
| /// | | /// | |
|
| /// \param Optimize : True to enable internal states optimizations, fal
se to go back to safe mode | | /// \param Preserve : True to preserve OpenGL states, false to let SFML
optimize | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| void OptimizeForNonOpenGL(bool Optimize); | | void PreserveOpenGLStates(bool Preserve); | |
| | | | |
| private : | | private : | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// /see Window::OnCreate | | /// /see Window::OnCreate | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| virtual void OnCreate(); | | virtual void OnCreate(); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// /see Window::OnDisplay | | /// /see Window::OnDisplay | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| virtual void OnDisplay(); | | virtual void OnDisplay(); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// /see Window::OnEvent | | | |
| /// | | | |
| //////////////////////////////////////////////////////////// | | | |
| virtual void OnEventReceived(const Event& EventReceived); | | | |
| | | | |
| //////////////////////////////////////////////////////////// | | | |
| /// Set the OpenGL render states needed for the SFML rendering | | /// Set the OpenGL render states needed for the SFML rendering | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| void SetRenderStates() const; | | void SetRenderStates() const; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| // Member data | | // Member data | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| Color myBackgroundColor; ///< Background color | | Color myBackgroundColor; ///< Background color | |
| View myDefaultView; ///< Default view | | View myDefaultView; ///< Default view | |
| FloatRect myCurrentRect; ///< Rectangle corresponding to the | | const View* myCurrentView; ///< Current active view | |
| current view | | bool myPreserveStates; ///< Should we preserve external OpenGL | |
| float myCurrentProjection[16]; ///< Projection matrix currently use | | states ? | |
| d by the window | | mutable bool myIsDrawing; ///< True when Draw is called from insi | |
| bool myOptimizeStates; ///< This flag is a hint, to save ma | | de, to allow some renderstates optimizations | |
| ny calls to the graphics driver when not mixing with OpenGL | | | |
| }; | | }; | |
| | | | |
| } // namespace sf | | } // namespace sf | |
| | | | |
| #endif // SFML_RENDERWINDOW_HPP | | #endif // SFML_RENDERWINDOW_HPP | |
| | | | |
End of changes. 16 change blocks. |
| 35 lines changed or deleted | | 54 lines changed or added | |
|
| Selector.hpp | | Selector.hpp | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| // | | // | |
| // SFML - Simple and Fast Multimedia Library | | // SFML - Simple and Fast Multimedia Library | |
|
| // Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com) | | // Copyright (C) 2007-2008 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_SELECTOR_HPP | | #ifndef SFML_SELECTOR_HPP | |
| #define SFML_SELECTOR_HPP | | #define SFML_SELECTOR_HPP | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| // Headers | | // Headers | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| #include <SFML/Network/SocketUDP.hpp> | | #include <SFML/Network/SocketUDP.hpp> | |
| #include <SFML/Network/SocketTCP.hpp> | | #include <SFML/Network/SocketTCP.hpp> | |
|
| #include <vector> | | #include <SFML/Network/SelectorBase.hpp> | |
| | | #include <map> | |
| | | | |
| namespace sf | | namespace sf | |
| { | | { | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Selector allow reading from multiple sockets | | /// Selector allow reading from multiple sockets | |
| /// without blocking. It's a kind of multiplexer | | /// without blocking. It's a kind of multiplexer | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| template <typename Type> | | template <typename Type> | |
|
| class Selector | | class Selector : private SelectorBase | |
| { | | { | |
| public : | | public : | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Default constructor | | | |
| /// | | | |
| //////////////////////////////////////////////////////////// | | | |
| Selector(); | | | |
| | | | |
| //////////////////////////////////////////////////////////// | | | |
| /// Add a socket to watch | | /// Add a socket to watch | |
| /// | | /// | |
| /// \param Socket : Socket to add | | /// \param Socket : Socket to add | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| void Add(Type Socket); | | void Add(Type Socket); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Remove a socket | | /// Remove a socket | |
| /// | | /// | |
| | | | |
| skipping to change at line 75 | | skipping to change at line 70 | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| void Remove(Type Socket); | | void Remove(Type Socket); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Remove all sockets | | /// Remove all sockets | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| void Clear(); | | void Clear(); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Retrieve all the sockets of the selector which are | | /// Wait and collect sockets which are ready for reading. | |
| /// ready for reading or writing. This functions will return | | /// This functions will return either when at least one socket | |
| /// either when at least one socket is ready, or when given time is out | | /// is ready, or when the given time is out | |
| /// | | /// | |
|
| /// \param Sockets : Array to fill with sockets that are ready for read
ing | | | |
| /// \param Timeout : Timeout, in seconds (0 by default : no timeout) | | /// \param Timeout : Timeout, in seconds (0 by default : no timeout) | |
| /// | | /// | |
|
| /// \return True if a socket is ready, false if time was out | | /// \return Number of sockets ready to be read | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| bool GetSocketsReady(std::vector<Type>& Sockets, float Timeout = 0.f); | | unsigned int Wait(float Timeout = 0.f); | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// After a call to Wait(), get the Index-th socket which is | |
| | | /// ready for reading. The total number of sockets ready | |
| | | /// is the integer returned by the previous call to Wait() | |
| | | /// | |
| | | /// \param Index : Index of the socket to get | |
| | | /// | |
| | | /// \return The Index-th socket | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | Type GetSocketReady(unsigned int Index) const; | |
| | | | |
| private : | | private : | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| | | // Types | |
| | | //////////////////////////////////////////////////////////// | |
| | | typedef std::map<SocketHelper::SocketType, Type> SocketTable; | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| // Member data | | // Member data | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| fd_set mySet; ///< Set of socket to watch | | SocketTable mySockets; ///< Table matching the SFML socket instances wi | |
| int myMaxSocket; ///< Maximum socket index | | th their low-level handles | |
| }; | | }; | |
| | | | |
| #include <SFML/Network/Selector.inl> | | #include <SFML/Network/Selector.inl> | |
| | | | |
| // Let's define the two only valid types of Selector | | // Let's define the two only valid types of Selector | |
| typedef Selector<SocketUDP> SelectorUDP; | | typedef Selector<SocketUDP> SelectorUDP; | |
| typedef Selector<SocketTCP> SelectorTCP; | | typedef Selector<SocketTCP> SelectorTCP; | |
| | | | |
| } // namespace sf | | } // namespace sf | |
| | | | |
| | | | |
End of changes. 10 change blocks. |
| 17 lines changed or deleted | | 28 lines changed or added | |
|
| Selector.inl | | Selector.inl | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| // | | // | |
| // SFML - Simple and Fast Multimedia Library | | // SFML - Simple and Fast Multimedia Library | |
|
| // Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com) | | // Copyright (C) 2007-2008 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 26 | | skipping to change at line 26 | |
| // in the product documentation would be appreciated but is not required
. | | // in the product documentation would be appreciated but is not required
. | |
| // | | // | |
| // 2. Altered source versions must be plainly marked as such, | | // 2. Altered source versions must be plainly marked as such, | |
| // 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. | |
| // | | // | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Default constructor | | | |
| //////////////////////////////////////////////////////////// | | | |
| template <typename Type> | | | |
| Selector<Type>::Selector() : | | | |
| myMaxSocket(0) | | | |
| { | | | |
| Clear(); | | | |
| } | | | |
| | | | |
| //////////////////////////////////////////////////////////// | | | |
| /// Add a socket to watch | | /// Add a socket to watch | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| template <typename Type> | | template <typename Type> | |
| void Selector<Type>::Add(Type Socket) | | void Selector<Type>::Add(Type Socket) | |
| { | | { | |
|
| FD_SET(Socket.mySocket, &mySet); | | if (Socket.IsValid()) | |
| | | { | |
| if (static_cast<int>(Socket.mySocket) > myMaxSocket) | | SelectorBase::Add(Socket.mySocket); | |
| myMaxSocket = static_cast<int>(Socket.mySocket); | | mySockets[Socket.mySocket] = Socket; | |
| | | } | |
| } | | } | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Remove a socket | | /// Remove a socket | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| template <typename Type> | | template <typename Type> | |
| void Selector<Type>::Remove(Type Socket) | | void Selector<Type>::Remove(Type Socket) | |
| { | | { | |
|
| FD_CLR(Socket.mySocket, &mySet); | | typename SocketTable::iterator It = mySockets.find(Socket.mySocket); | |
| | | if (It != mySockets.end()) | |
| | | { | |
| | | SelectorBase::Remove(Socket.mySocket); | |
| | | mySockets.erase(It); | |
| | | } | |
| } | | } | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Remove all sockets | | /// Remove all sockets | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| template <typename Type> | | template <typename Type> | |
| void Selector<Type>::Clear() | | void Selector<Type>::Clear() | |
| { | | { | |
|
| FD_ZERO(&mySet); | | SelectorBase::Clear(); | |
| | | mySockets.clear(); | |
| myMaxSocket = 0; | | | |
| } | | } | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Retrieve all the sockets of the selector which are | | /// Wait and collect sockets which are ready for reading. | |
| /// ready for reading or writing. This functions will return | | /// This functions will return either when at least one socket | |
| /// either when at least one socket is ready, or when given time is out | | /// is ready, or when the given time is out | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| template <typename Type> | | template <typename Type> | |
|
| bool Selector<Type>::GetSocketsReady(std::vector<Type>& Sockets, float Time
out) | | unsigned int Selector<Type>::Wait(float Timeout) | |
| { | | { | |
|
| // First of all, clear the array to fill... | | // No socket in the selector : return 0 | |
| Sockets.clear(); | | if (mySockets.empty()) | |
| | | return 0; | |
| // Setup the timeout structure | | | |
| timeval Time; | | | |
| Time.tv_sec = static_cast<long>(Timeout); | | | |
| Time.tv_usec = (static_cast<long>(Timeout * 1000) % 1000) * 1000; | | | |
| | | | |
|
| // Use a copy of the set, as it will be modified by select() | | return SelectorBase::Wait(Timeout); | |
| fd_set Set = mySet; | | } | |
| | | | |
|
| // Wait until one of the sockets is ready for reading, or timeout is re | | //////////////////////////////////////////////////////////// | |
| ached | | /// After a call to Wait(), get the Index-th socket which is | |
| if (select(myMaxSocket + 1, &Set, NULL, NULL, Timeout > 0 ? &Time : NUL | | /// ready for reading. The total number of sockets ready | |
| L) != 0) | | /// is the integer returned by the previous call to Wait() | |
| { | | //////////////////////////////////////////////////////////// | |
| // One or more sockets are ready : put them into the array | | template <typename Type> | |
| for (int i = 0; i < myMaxSocket + 1; ++i) | | Type Selector<Type>::GetSocketReady(unsigned int Index) const | |
| { | | { | |
| if (FD_ISSET(i, &Set)) | | SocketHelper::SocketType Socket = SelectorBase::GetSocketReady(Index); | |
| Sockets.push_back(Type(static_cast<SocketHelper::SocketType | | | |
| >(i))); | | | |
| } | | | |
| | | | |
|
| return true; | | typename SocketTable::const_iterator It = mySockets.find(Socket); | |
| } | | if (It != mySockets.end()) | |
| | | return It->second; | |
| else | | else | |
|
| { | | return Type(Socket); | |
| // Timeout reached... | | | |
| return false; | | | |
| } | | | |
| } | | } | |
| | | | |
End of changes. 12 change blocks. |
| 50 lines changed or deleted | | 36 lines changed or added | |
|
| Sound.hpp | | Sound.hpp | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| // | | // | |
| // SFML - Simple and Fast Multimedia Library | | // SFML - Simple and Fast Multimedia Library | |
|
| // Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com) | | // Copyright (C) 2007-2008 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_SOUND_HPP | | #ifndef SFML_SOUND_HPP | |
| #define SFML_SOUND_HPP | | #define SFML_SOUND_HPP | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| // Headers | | // Headers | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| #include <cstdlib> | | #include <cstdlib> | |
| #include <SFML/Audio/AudioResource.hpp> | | #include <SFML/Audio/AudioResource.hpp> | |
|
| | | #include <SFML/System/Vector3.hpp> | |
| | | | |
| namespace sf | | namespace sf | |
| { | | { | |
| class SoundBuffer; | | class SoundBuffer; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Sound defines the properties of the sound such as position, | | /// Sound defines the properties of the sound such as position, | |
| /// volume, pitch, etc. | | /// volume, pitch, etc. | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| class SFML_API Sound : public AudioResource | | class SFML_API Sound : public AudioResource | |
| | | | |
| skipping to change at line 65 | | skipping to change at line 66 | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Default constructor | | /// Default constructor | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| Sound(); | | Sound(); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Construct the sound from its parameters | | /// Construct the sound from its parameters | |
| /// | | /// | |
|
| /// \param Buffer : Sound buffer to play (NULL by default) | | /// \param Buffer : Sound buffer to play (NULL by default) | |
| /// \param Loop : Loop flag (false by default) | | /// \param Loop : Loop flag (false by default) | |
| /// \param Pitch : Value of the pitch (1 by default) | | /// \param Pitch : Value of the pitch (1 by default) | |
| /// \param Volume : Volume (100 by default) | | /// \param Volume : Volume (100 by default) | |
| /// \param X : X position (0 by default) | | /// \param Position : Position (0, 0, 0 by default) | |
| /// \param Y : Y position (0 by default) | | | |
| /// \param Z : Z position (0 by default) | | | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| Sound(const SoundBuffer& Buffer, bool Loop = false, float Pitch = 1.f,
float Volume = 100.f, float X = 0.f, float Y = 0.f, float Z = 0.f); | | Sound(const SoundBuffer& Buffer, bool Loop = false, float Pitch = 1.f,
float Volume = 100.f, const Vector3f& Position = Vector3f(0, 0, 0)); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Copy constructor | | /// Copy constructor | |
| /// | | /// | |
| /// \param Copy : Instance to copy | | /// \param Copy : Instance to copy | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| Sound(const Sound& Copy); | | Sound(const Sound& Copy); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| | | | |
| skipping to change at line 144 | | skipping to change at line 143 | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Set the sound volume. | | /// Set the sound volume. | |
| /// The default volume is 100 | | /// The default volume is 100 | |
| /// | | /// | |
| /// \param Volume : Volume (in range [0, 100]) | | /// \param Volume : Volume (in range [0, 100]) | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| void SetVolume(float Volume); | | void SetVolume(float Volume); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Set the sound position. | | /// Set the sound position (take 3 values). | |
| /// The default position is (0, 0, 0) | | /// The default position is (0, 0, 0) | |
| /// | | /// | |
|
| /// \param X : X position of the sound in the world | | /// \param X, Y, Z : Position of the sound in the world | |
| /// \param Y : Y position of the sound in the world | | | |
| /// \param Z : Z position of the sound in the world | | | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| void SetPosition(float X, float Y, float Z); | | void SetPosition(float X, float Y, float Z); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| | | /// Set the sound position (take a 3D vector). | |
| | | /// The default position is (0, 0, 0) | |
| | | /// | |
| | | /// \param Position : Position of the sound in the world | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | void SetPosition(const Vector3f& Position); | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Set the minimum distance - closer than this distance, | |
| | | /// the listener will hear the sound at its maximum volume. | |
| | | /// The default minimum distance is 1.0 | |
| | | /// | |
| | | /// \param MinDistance : New minimum distance for the sound | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | void SetMinDistance(float MinDistance); | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Set the attenuation factor - the higher the attenuation, the | |
| | | /// more the sound will be attenuated with distance from listener. | |
| | | /// The default attenuation factor 1.0 | |
| | | /// | |
| | | /// \param Attenuation : New attenuation factor for the sound | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | void SetAttenuation(float Attenuation); | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| /// Get the source buffer | | /// Get the source buffer | |
| /// | | /// | |
| /// \return Sound buffer bound to the sound (can be NULL) | | /// \return Sound buffer bound to the sound (can be NULL) | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| const SoundBuffer* GetBuffer() const; | | const SoundBuffer* GetBuffer() const; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Tell whether or not the sound is looping | | /// Tell whether or not the sound is looping | |
| /// | | /// | |
| | | | |
| skipping to change at line 189 | | skipping to change at line 215 | |
| /// Get the volume | | /// Get the volume | |
| /// | | /// | |
| /// \return Volume value (in range [1, 100]) | | /// \return Volume value (in range [1, 100]) | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| float GetVolume() const; | | float GetVolume() const; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Get the sound position | | /// Get the sound position | |
| /// | | /// | |
|
| /// \param X : X position of the sound in the world | | /// \return Position of the sound in the world | |
| /// \param Y : Y position of the sound in the world | | /// | |
| /// \param Z : Z position of the sound in the world | | //////////////////////////////////////////////////////////// | |
| | | Vector3f GetPosition() const; | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Get the minimum distance | |
| | | /// | |
| | | /// \return Minimum distance for the sound | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | float GetMinDistance() const; | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Get the attenuation factor | |
| | | /// | |
| | | /// \return Attenuation factor of the sound | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| void GetPosition(float& X, float& Y, float& Z) const; | | float GetAttenuation() const; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Get the status of the sound (stopped, paused, playing) | | /// Get the status of the sound (stopped, paused, playing) | |
| /// | | /// | |
| /// \return Current status of the sound | | /// \return Current status of the sound | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| Status GetStatus() const; | | Status GetStatus() const; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| | | | |
End of changes. 9 change blocks. |
| 17 lines changed or deleted | | 57 lines changed or added | |
|
| Sprite.hpp | | Sprite.hpp | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| // | | // | |
| // SFML - Simple and Fast Multimedia Library | | // SFML - Simple and Fast Multimedia Library | |
|
| // Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com) | | // Copyright (C) 2007-2008 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 56 | | skipping to change at line 56 | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Default constructor | | /// Default constructor | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| Sprite(); | | Sprite(); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Construct the sprite from a source image | | /// Construct the sprite from a source image | |
| /// | | /// | |
| /// \param Img : Image of the sprite | | /// \param Img : Image of the sprite | |
|
| /// \param Left : Left coordinate of the sprite (0 by default) | | /// \param Position : Position of the sprite (0, 0 by default) | |
| /// \param Top : Top coordinate of the sprite (0 by default) | | /// \param Scale : Scale factor (1, 1 by default) | |
| /// \param ScaleX : Horizontal scale (1 by default) | | | |
| /// \param ScaleY : Vertical scale (1 by default) | | | |
| /// \param Rotation : Orientation, in degrees (0 by default) | | /// \param Rotation : Orientation, in degrees (0 by default) | |
| /// \param Col : Color of the sprite (white by default) | | /// \param Col : Color of the sprite (white by default) | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| Sprite(const Image& Img, float Left = 0.f, float Top = 0.f, float Scale
X = 1.f, float ScaleY = 1.f, float Rotation = 0.f, const Color& Col = Color
(255, 255, 255, 255)); | | Sprite(const Image& Img, const Vector2f& Position = Vector2f(0, 0), con
st Vector2f& Scale = Vector2f(1, 1), float Rotation = 0.f, const Color& Col
= Color(255, 255, 255, 255)); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Change the image of the sprite | | /// Change the image of the sprite | |
| /// | | /// | |
| /// \param Img : New image | | /// \param Img : New image | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| void SetImage(const Image& Img); | | void SetImage(const Image& Img); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Set the sub-rectangle of the sprite inside the source image. | | /// Set the sub-rectangle of the sprite inside the source image. | |
| /// By default, the subrect covers the entire source image | | /// By default, the subrect covers the entire source image | |
| /// | | /// | |
| /// \param SubRect : New sub-rectangle | | /// \param SubRect : New sub-rectangle | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| void SetSubRect(const IntRect& SubRect); | | void SetSubRect(const IntRect& SubRect); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Resize the sprite (by changing its scale factors). | | /// Resize the sprite (by changing its scale factors) (take 2 values). | |
| /// The default size is defined by the subrect | | /// The default size is defined by the subrect | |
| /// | | /// | |
| /// \param Width : New width (must be strictly positive) | | /// \param Width : New width (must be strictly positive) | |
| /// \param Height : New height (must be strictly positive) | | /// \param Height : New height (must be strictly positive) | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| void Resize(float Width, float Height); | | void Resize(float Width, float Height); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| | | /// Resize the sprite (by changing its scale factors) (take a 2D vector | |
| | | ). | |
| | | /// The default size is defined by the subrect | |
| | | /// | |
| | | /// \param Size : New size (both coordinates must be strictly positive) | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | void Resize(const Vector2f& Size); | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| /// Flip the sprite horizontally | | /// Flip the sprite horizontally | |
| /// | | /// | |
| /// \param Flipped : True to flip the sprite | | /// \param Flipped : True to flip the sprite | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| void FlipX(bool Flipped); | | void FlipX(bool Flipped); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Flip the sprite vertically | | /// Flip the sprite vertically | |
| /// | | /// | |
| | | | |
| skipping to change at line 126 | | skipping to change at line 133 | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Get the sub-rectangle of the sprite inside the source image | | /// Get the sub-rectangle of the sprite inside the source image | |
| /// | | /// | |
| /// \return Sub-rectangle | | /// \return Sub-rectangle | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| const IntRect& GetSubRect() const; | | const IntRect& GetSubRect() const; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Get the sprite width | | /// Get the sprite size | |
| /// | | | |
| /// \return Width of the sprite | | | |
| /// | | | |
| //////////////////////////////////////////////////////////// | | | |
| float GetWidth() const; | | | |
| | | | |
| //////////////////////////////////////////////////////////// | | | |
| /// Get the sprite height | | | |
| /// | | /// | |
|
| /// \return Height of the sprite | | /// \return Size of the sprite | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| float GetHeight() const; | | Vector2f GetSize() const; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Get the color of a given pixel in the sprite | | /// Get the color of a given pixel in the sprite | |
| /// | | /// | |
| /// \param X : X coordinate of the pixel to get | | /// \param X : X coordinate of the pixel to get | |
| /// \param Y : Y coordinate of the pixel to get | | /// \param Y : Y coordinate of the pixel to get | |
| /// | | /// | |
| /// \return Color of pixel (X, Y) | | /// \return Color of pixel (X, Y) | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| | | | |
End of changes. 8 change blocks. |
| 18 lines changed or deleted | | 18 lines changed or added | |
|
| String.hpp | | String.hpp | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| // | | // | |
| // SFML - Simple and Fast Multimedia Library | | // SFML - Simple and Fast Multimedia Library | |
|
| // Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com) | | // Copyright (C) 2007-2008 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_STRING_HPP | | #ifndef SFML_STRING_HPP | |
| #define SFML_STRING_HPP | | #define SFML_STRING_HPP | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| // Headers | | // Headers | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| #include <SFML/Graphics/Drawable.hpp> | | #include <SFML/Graphics/Drawable.hpp> | |
|
| | | #include <SFML/Graphics/Font.hpp> | |
| #include <SFML/Graphics/Rect.hpp> | | #include <SFML/Graphics/Rect.hpp> | |
| #include <string> | | #include <string> | |
| | | | |
| namespace sf | | namespace sf | |
| { | | { | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// String defines a graphical 2D text, that can be drawn on screen | | /// String defines a graphical 2D text, that can be drawn on screen | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| class SFML_API String : public Drawable | | class SFML_API String : public Drawable | |
| { | | { | |
| public : | | public : | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Construct the string from a multibyte text | | /// Enumerate the string drawing styles | |
| /// | | | |
| /// \param Text : Text assigned to the string ("" by default) | | | |
| /// \param Font : Font used to draw the string ("" by default - use def | | | |
| ault font) | | | |
| /// \param Size : Characters size, in pixels (32 by default) | | | |
| /// | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| String(const std::string& Text, const std::string& Font = "", float Siz | | enum Style | |
| e = 32.f); | | { | |
| | | Regular = 0, ///< Regular characters, no style | |
| | | Bold = 1 << 0, ///< Characters are bold | |
| | | Italic = 1 << 1, ///< Characters are in italic | |
| | | Underlined = 1 << 2 ///< Characters are underlined | |
| | | }; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Construct the string from a unicode text | | /// Construct the string from a multibyte text | |
| /// | | /// | |
|
| /// \param Text : Text assigned to the string ("" by default) | | /// \param Text : Text assigned to the string | |
| /// \param Font : Font used to draw the string ("" by default - use def | | /// \param Font : Font used to draw the string (SFML built-in font by d | |
| ault font) | | efault) | |
| /// \param Size : Characters size, in pixels (32 by default) | | /// \param Size : Characters size (30 by default) | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| String(const std::wstring& Text = L"", const std::string& Font = "", fl
oat Size = 32.f); | | String(const std::string& Text, const Font& CharFont = Font::GetDefault
Font(), float Size = 30.f); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Preload a bitmap font (otherwise, it is done the first time the fon
t is drawn) | | /// Construct the string from a unicode text | |
| /// | | /// | |
|
| /// \param Font : Font to load | | /// \param Text : Text assigned to the string ("" by default) | |
| /// \param Size : Requested character size | | /// \param Font : Font used to draw the string (SFML built-in font by d | |
| /// \param Charset : Characters set to generate (empty by default - tak | | efault) | |
| e the ASCII range [31, 255]) | | /// \param Size : Characters size (30 by default) | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| static void PreloadFont(const std::string& Font, float Size, std::wstri
ng Charset = L""); | | String(const std::wstring& Text = L"", const Font& CharFont = Font::Get
DefaultFont(), float Size = 30.f); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Set the text (from a multibyte string) | | /// Set the text (from a multibyte string) | |
| /// | | /// | |
| /// \param Text : New text | | /// \param Text : New text | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| void SetText(const std::string& Text); | | void SetText(const std::string& Text); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Set the text (from a unicode string) | | /// Set the text (from a unicode string) | |
| /// | | /// | |
| /// \param Text : New text | | /// \param Text : New text | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| void SetText(const std::wstring& Text); | | void SetText(const std::wstring& Text); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Set the font of the string | | /// Set the font of the string | |
| /// | | /// | |
|
| /// \param Font : Font filename | | /// \param Font : Font to use | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| void SetFont(const std::string& Font); | | void SetFont(const Font& CharFont); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Set the size of the string | | /// Set the size of the string | |
|
| | | /// The default size is 30 | |
| /// | | /// | |
| /// \param Size : New size, in pixels | | /// \param Size : New size, in pixels | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| void SetSize(float Size); | | void SetSize(float Size); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| | | /// Set the style of the text | |
| | | /// The default style is Regular | |
| | | /// | |
| | | /// \param TextStyle : New text style, (combination of Style enum value | |
| | | s) | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | void SetStyle(unsigned long TextStyle); | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| /// Get the text (returns a unicode string) | | /// Get the text (returns a unicode string) | |
| /// | | /// | |
| /// \return Text | | /// \return Text | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| const std::wstring& GetUnicodeText() const; | | const std::wstring& GetUnicodeText() const; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Get the text (returns a multibyte string) | | /// Get the text (returns a multibyte string) | |
| /// | | /// | |
| /// \return Text | | /// \return Text | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| std::string GetText() const; | | std::string GetText() const; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Get the font used by the string | | /// Get the font used by the string | |
| /// | | /// | |
|
| /// \return Font name | | /// \return Font used | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| const std::string& GetFont() const; | | const Font& GetFont() const; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// Get the size of the characters | | /// Get the size of the characters | |
| /// | | /// | |
| /// \return Size of the characters | | /// \return Size of the characters | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| float GetSize() const; | | float GetSize() const; | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| | | /// Get the style of the text | |
| | | /// | |
| | | /// \return Current string style (combination of Style enum values) | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | unsigned long GetStyle() const; | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| /// Get the string rectangle on screen | | /// Get the string rectangle on screen | |
| /// | | /// | |
| /// \return Rectangle contaning the string in screen coordinates | | /// \return Rectangle contaning the string in screen coordinates | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| FloatRect GetRect() const; | | FloatRect GetRect() const; | |
| | | | |
| protected : | | protected : | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| /// /see Drawable::Render | | /// /see Drawable::Render | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| virtual void Render(const RenderWindow& Window) const; | | virtual void Render(const RenderWindow& Window) const; | |
| | | | |
| private : | | private : | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| | | /// Recompute the bounding rectangle of the text | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | void RecomputeRect(); | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| // Member data | | // Member data | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| std::wstring myText; ///< Text to display | | std::wstring myText; ///< Text to display | |
| std::string myFont; ///< Font used to display string | | const Font* myFont; ///< Font used to display the string | |
| float mySize; ///< Size of characters (in pixels) (must be stric | | float mySize; ///< Size of the characters | |
| tly positive) | | unsigned long myStyle; ///< Text style (see Style enum) | |
| | | FloatRect myBaseRect; ///< Bounding rectangle of the text in | |
| | | object coordinates | |
| | | bool myNeedRectUpdate; ///< Does the bounding rect need an upd | |
| | | ate ? | |
| }; | | }; | |
| | | | |
| } // namespace sf | | } // namespace sf | |
| | | | |
| #endif // SFML_STRING_HPP | | #endif // SFML_STRING_HPP | |
| | | | |
End of changes. 19 change blocks. |
| 30 lines changed or deleted | | 59 lines changed or added | |
|
| View.hpp | | View.hpp | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| // | | // | |
| // SFML - Simple and Fast Multimedia Library | | // SFML - Simple and Fast Multimedia Library | |
|
| // Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com) | | // Copyright (C) 2007-2008 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_VIEW_HPP | | #ifndef SFML_VIEW_HPP | |
| #define SFML_VIEW_HPP | | #define SFML_VIEW_HPP | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| // Headers | | // Headers | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| #include <SFML/Config.hpp> | | #include <SFML/Config.hpp> | |
| #include <SFML/Graphics/Rect.hpp> | | #include <SFML/Graphics/Rect.hpp> | |
|
| | | #include <SFML/Graphics/Matrix3.hpp> | |
| | | #include <SFML/System/Vector2.hpp> | |
| | | | |
| namespace sf | | namespace sf | |
| { | | { | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// This class defines a view (position, size and zoom) ; | | /// This class defines a view (position, size, etc.) ; | |
| /// you can consider it as a camera | | /// you can consider it as a 2D camera | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| class SFML_API View | | class SFML_API View | |
| { | | { | |
| public : | | public : | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| /// Construct the view with position and size | | /// Construct the view from a rectangle | |
| | | /// | |
| | | /// \param ViewRect : Rectangle defining the position and size of the v | |
| | | iew (1000x1000 by default) | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | explicit View(const FloatRect& ViewRect = FloatRect(0, 0, 1000, 1000)); | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Construct the view from its center and half-size | |
| | | /// | |
| | | /// \param Center : Center of the view | |
| | | /// \param HalfSize : Half-size of the view (from center to corner) | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | View(const sf::Vector2f& Center, const sf::Vector2f& HalfSize); | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Change the center of the view (take 2 values) | |
| | | /// | |
| | | /// \param X : X coordinate of the new center | |
| | | /// \param Y : Y coordinate of the new center | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | void SetCenter(float X, float Y); | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Change the center of the view (take a vector) | |
| | | /// | |
| | | /// \param Center : New center | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | void SetCenter(const sf::Vector2f& Center); | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Change the half-size of the view (take 2 values) | |
| | | /// | |
| | | /// \param HalfWidth : New half-width | |
| | | /// \param HalfHeight : New half-height | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | void SetHalfSize(float HalfWidth, float HalfHeight); | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Change the half-size of the view (take a vector) | |
| | | /// | |
| | | /// \param HalfSize : New half-size | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | void SetHalfSize(const sf::Vector2f& HalfSize); | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Rebuild the view from a rectangle | |
| /// | | /// | |
| /// \param ViewRect : Rectangle defining the position and size of the v
iew | | /// \param ViewRect : Rectangle defining the position and size of the v
iew | |
|
| /// \param ViewZoom : Zoom factor (1 by default) | | | |
| /// | | /// | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| View(const FloatRect& ViewRect = FloatRect(0, 0, 1000, 1000), float Vie | | void SetFromRect(const FloatRect& ViewRect); | |
| wZoom = 1.f); | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Get the center of the view | |
| | | /// | |
| | | /// \return Center of the view | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | const sf::Vector2f& GetCenter() const; | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Get the half-size of the view | |
| | | /// | |
| | | /// \return Half-size of the view | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | const sf::Vector2f& GetHalfSize() const; | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Get the bounding rectangle of the view | |
| | | /// | |
| | | /// \return Bounding rectangle of the view | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | const sf::FloatRect& GetRect() const; | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Move the view (take 2 values) | |
| | | /// | |
| | | /// \param OffsetX : Offset to move the view, on X axis | |
| | | /// \param OffsetY : Offset to move the view, on Y axis | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | void Move(float OffsetX, float OffsetY); | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Move the view (take a vector) | |
| | | /// | |
| | | /// \param Offset : Offset to move the view | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | void Move(const sf::Vector2f& Offset); | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Resize the view rectangle to simulate a zoom / unzoom effect | |
| | | /// | |
| | | /// \param Factor : Zoom factor to apply, relative to the current zoom | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | void Zoom(float Factor); | |
| | | | |
| | | private : | |
| | | | |
| | | friend class RenderWindow; | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Get the projection matrix of the view | |
| | | /// | |
| | | /// \return Projection matrix containing the view settings | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | const Matrix3& GetMatrix() const; | |
| | | | |
| | | //////////////////////////////////////////////////////////// | |
| | | /// Recompute the view rectangle and the projection matrix | |
| | | /// | |
| | | //////////////////////////////////////////////////////////// | |
| | | void RecomputeMatrix(); | |
| | | | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
| // Member data | | // Member data | |
| //////////////////////////////////////////////////////////// | | //////////////////////////////////////////////////////////// | |
|
| FloatRect Rect; ///< Rectangle defining the view's position and size | | sf::Vector2f myCenter; ///< Center of the view | |
| float Zoom; ///< Zoom (less than 1 is unzoom, greater than 1 is zoo | | sf::Vector2f myHalfSize; ///< Half-size of the view | |
| m) | | FloatRect myRect; ///< Rectangle defining the bounds of the vi | |
| | | ew | |
| | | Matrix3 myMatrix; ///< Precomputed projection matrix correspon | |
| | | ding to the view | |
| | | bool myNeedUpdate; ///< Internal state telling if the matrix ne | |
| | | eds to be updated | |
| }; | | }; | |
| | | | |
| } // namespace sf | | } // namespace sf | |
| | | | |
| #endif // SFML_VIEW_HPP | | #endif // SFML_VIEW_HPP | |
| | | | |
End of changes. 7 change blocks. |
| 10 lines changed or deleted | | 134 lines changed or added | |
|