Added viewport handling in sf::View

Upgraded SFML.Net project files to VS2008

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1155 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2009-06-26 13:24:29 +00:00
parent 1bb96087ad
commit 7cc00085d8
24 changed files with 361 additions and 102 deletions

View file

@ -104,15 +104,28 @@ public :
////////////////////////////////////////////////////////////
/// Convert a point in window coordinates into view coordinates
/// This version uses the current view of the window
///
/// \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 default -- uses the current view)
/// \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
///
/// \return Converted point
///
////////////////////////////////////////////////////////////
sf::Vector2f ConvertCoords(unsigned int WindowX, unsigned int WindowY, const View* TargetView = NULL) const;
sf::Vector2f ConvertCoords(unsigned int WindowX, unsigned int WindowY) const;
////////////////////////////////////////////////////////////
/// Convert a point in window coordinates into view coordinates
/// This version uses the given view
///
/// \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
///
/// \return Converted point
///
////////////////////////////////////////////////////////////
sf::Vector2f ConvertCoords(unsigned int WindowX, unsigned int WindowY, const View& TargetView) const;
private :

View file

@ -116,6 +116,21 @@ public :
////////////////////////////////////////////////////////////
void SetRotation(float Angle);
////////////////////////////////////////////////////////////
/// Set the target viewport
///
/// The viewport is the rectangle into which the contents of the
/// view are displayed, expressed as a factor (between 0 and 1)
/// of the size of the RenderTarget to which the view is applied.
///
/// For example, a view which takes the left side of the target would
/// be defined with View.SetViewport(sf::FloatRect(0, 0, 0.5, 1)).
///
/// \param Viewport : New viewport
///
////////////////////////////////////////////////////////////
void SetViewport(const FloatRect& Viewport);
////////////////////////////////////////////////////////////
/// Reset the view to the given rectangle.
/// Note: this function resets the rotation angle to 0.
@ -141,6 +156,22 @@ public :
////////////////////////////////////////////////////////////
const Vector2f& GetSize() const;
////////////////////////////////////////////////////////////
/// Get the current rotation
///
/// \return Rotation of the view, in degrees
///
////////////////////////////////////////////////////////////
float GetRotation() const;
////////////////////////////////////////////////////////////
/// Get the target viewport
///
/// \return Viewport rectangle, expressed as a factor of the target size
///
////////////////////////////////////////////////////////////
const FloatRect& GetViewport() const;
////////////////////////////////////////////////////////////
/// Move the view
///
@ -198,6 +229,7 @@ private :
Vector2f myCenter; ///< Center of the view, in scene coordinates
Vector2f mySize; ///< Size of the view, in scene coordinates
float myRotation; ///< Angle of rotation of the view rectangle, in degrees
FloatRect myViewport; ///< Viewport rectangle, expressed as a factor of the render-target's size
mutable Matrix3 myMatrix; ///< Precomputed projection matrix corresponding to the view
mutable Matrix3 myInverseMatrix; ///< Precomputed inverse projection matrix corresponding to the view
mutable bool myNeedUpdate; ///< Internal state telling if the matrix needs to be updated