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

@ -220,12 +220,15 @@ EXPORTS
sfView_CreateFromRect
sfView_Destroy
sfView_SetCenter
sfView_SetHalfSize
sfView_SetFromRect
sfView_SetSize
sfView_SetRotation
sfView_SetViewport
sfView_Reset
sfView_GetCenterX
sfView_GetCenterY
sfView_GetHalfSizeX
sfView_GetHalfSizeY
sfView_GetRect
sfView_GetWidth
sfView_GetHeight
sfView_GetViewport
sfView_Move
sfView_Rotate
sfView_Zoom

View file

@ -220,12 +220,15 @@ EXPORTS
sfView_CreateFromRect
sfView_Destroy
sfView_SetCenter
sfView_SetHalfSize
sfView_SetFromRect
sfView_SetSize
sfView_SetRotation
sfView_SetViewport
sfView_Reset
sfView_GetCenterX
sfView_GetCenterY
sfView_GetHalfSizeX
sfView_GetHalfSizeY
sfView_GetRect
sfView_GetWidth
sfView_GetHeight
sfView_GetViewport
sfView_Move
sfView_Rotate
sfView_Zoom

View file

@ -66,23 +66,46 @@ CSFML_API void sfView_Destroy(sfView* View);
CSFML_API void sfView_SetCenter(sfView* View, float X, float Y);
////////////////////////////////////////////////////////////
/// Change the half-size of a view
/// Change the size of a view
///
/// \param View : View to modify
/// \param HalfWidth : New half-width
/// \param HalfHeight : New half-height
/// \param View : View to modify
/// \param Width : New width
/// \param Height : New height
///
////////////////////////////////////////////////////////////
CSFML_API void sfView_SetHalfSize(sfView* View, float HalfWidth, float HalfHeight);
CSFML_API void sfView_SetSize(sfView* View, float Width, float Height);
////////////////////////////////////////////////////////////
/// Rebuild a view from a rectangle
/// Set the angle of rotation of a view
///
/// \param View : View to modify
/// \param ViewRect : Rectangle defining the position and size of the view
/// \param View : View to modify
/// \param Angle : New angle, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfView_SetFromRect(sfView* View, sfFloatRect ViewRect);
CSFML_API void sfView_SetRotation(sfView* View, float Angle);
////////////////////////////////////////////////////////////
/// Set the target viewport of a view
///
/// 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.
///
/// \param View : View to modify
/// \param Viewport : New viewport
///
////////////////////////////////////////////////////////////
CSFML_API void sfView_SetViewport(sfView* View, sfFloatRect Viewport);
////////////////////////////////////////////////////////////
/// Reset a view to the given rectangle.
/// Note: this function resets the rotation angle to 0.
///
/// \param View : View to modify
/// \param Rectangle : Rectangle defining the position and size of the view
///
////////////////////////////////////////////////////////////
CSFML_API void sfView_Reset(sfView* View, sfFloatRect Rectangle);
////////////////////////////////////////////////////////////
/// Get the X coordinate of the center of a view
@ -105,34 +128,44 @@ CSFML_API float sfView_GetCenterX(sfView* View);
CSFML_API float sfView_GetCenterY(sfView* View);
////////////////////////////////////////////////////////////
/// Get the half-width of the view
/// Get the width of the view
///
/// \param View : View to read
///
/// \return Half-width of the view
/// \return Width of the view
///
////////////////////////////////////////////////////////////
CSFML_API float sfView_GetHalfSizeX(sfView* View);
CSFML_API float sfView_GetWidth(sfView* View);
////////////////////////////////////////////////////////////
/// Get the half-height of the view
/// Get the height of the view
///
/// \param View : View to read
///
/// \return Half-height of the view
/// \return Height of the view
///
////////////////////////////////////////////////////////////
CSFML_API float sfView_GetHalfSizeY(sfView* View);
CSFML_API float sfView_GetHeight(sfView* View);
////////////////////////////////////////////////////////////
/// Get the bounding rectangle of a view
/// Get the current rotation of a view
///
/// \param View : View to read
///
/// \return Bounding rectangle of the view
/// \return Rotation of the view, in degrees
///
////////////////////////////////////////////////////////////
CSFML_API sfFloatRect sfView_GetRect(sfView* View);
CSFML_API float sfView_GetRotation(sfView* View);
////////////////////////////////////////////////////////////
/// Get the target viewport of a view
///
/// \param View : View to read
///
/// \return Viewport rectangle, expressed as a factor of the target size
///
////////////////////////////////////////////////////////////
CSFML_API sfFloatRect sfView_GetViewport(sfView* View);
////////////////////////////////////////////////////////////
/// Move a view
@ -144,6 +177,15 @@ CSFML_API sfFloatRect sfView_GetRect(sfView* View);
////////////////////////////////////////////////////////////
CSFML_API void sfView_Move(sfView* View, float OffsetX, float OffsetY);
////////////////////////////////////////////////////////////
/// Rotate a view
///
/// \param View : View to rotate
/// \param Angle : Angle in degrees
///
////////////////////////////////////////////////////////////
CSFML_API void sfView_Rotate(sfView* View, float Angle);
////////////////////////////////////////////////////////////
/// Resize a view rectangle to simulate a zoom / unzoom effect
///

View file

@ -80,7 +80,7 @@ sfBool sfFloatRect_Intersects(sfFloatRect* Rect1, sfFloatRect* Rect2, sfFloatRec
if (OverlappingRect)
{
sf::FloatRect Overlap;
bool Intersect = SFMLRect1.Intersects(SFMLRect2, &Overlap);
bool Intersect = SFMLRect1.Intersects(SFMLRect2, Overlap);
OverlappingRect->Left = Overlap.Left;
OverlappingRect->Top = Overlap.Top;
@ -105,7 +105,7 @@ sfBool sfIntRect_Intersects(sfIntRect* Rect1, sfIntRect* Rect2, sfIntRect* Overl
if (OverlappingRect)
{
sf::IntRect Overlap;
bool Intersect = SFMLRect1.Intersects(SFMLRect2, &Overlap);
bool Intersect = SFMLRect1.Intersects(SFMLRect2, Overlap);
OverlappingRect->Left = Overlap.Left;
OverlappingRect->Top = Overlap.Top;

View file

@ -429,7 +429,11 @@ void sfRenderWindow_ConvertCoords(sfRenderWindow* RenderWindow, unsigned int Win
{
CSFML_CHECK(RenderWindow);
sf::Vector2f Point = RenderWindow->This.ConvertCoords(WindowX, WindowY, TargetView ? TargetView->This : NULL);
sf::Vector2f Point;
if (TargetView)
Point = RenderWindow->This.ConvertCoords(WindowX, WindowY, *TargetView->This);
else
Point = RenderWindow->This.ConvertCoords(WindowX, WindowY);
if (ViewX) *ViewX = Point.x;
if (ViewY) *ViewY = Point.y;

View file

@ -67,20 +67,39 @@ void sfView_SetCenter(sfView* View, float X, float Y)
////////////////////////////////////////////////////////////
/// Change the half-size of a view
/// Change the size of a view
////////////////////////////////////////////////////////////
void sfView_SetHalfSize(sfView* View, float HalfWidth, float HalfHeight)
void sfView_SetSize(sfView* View, float Width, float Height)
{
CSFML_CALL_PTR(View, SetHalfSize(HalfWidth, HalfHeight));
CSFML_CALL_PTR(View, SetSize(Width, Height));
}
////////////////////////////////////////////////////////////
/// Rebuild a view from a rectangle
/// Set the angle of rotation of a view
////////////////////////////////////////////////////////////
void sfView_SetFromRect(sfView* View, sfFloatRect ViewRect)
void sfView_SetRotation(sfView* View, float Angle)
{
CSFML_CALL_PTR(View, SetFromRect(sf::FloatRect(ViewRect.Left, ViewRect.Top, ViewRect.Right, ViewRect.Bottom)));
CSFML_CALL_PTR(View, SetRotation(Angle));
}
////////////////////////////////////////////////////////////
/// Set the target viewport of a view
////////////////////////////////////////////////////////////
void sfView_SetViewport(sfView* View, sfFloatRect Viewport)
{
CSFML_CALL_PTR(View, SetViewport(sf::FloatRect(Viewport.Left, Viewport.Top, Viewport.Right, Viewport.Bottom)));
}
////////////////////////////////////////////////////////////
/// Reset a view to the given rectangle.
/// Note: this function resets the rotation angle to 0.
////////////////////////////////////////////////////////////
void sfView_Reset(sfView* View, sfFloatRect Rectangle)
{
CSFML_CALL_PTR(View, Reset(sf::FloatRect(Rectangle.Left, Rectangle.Top, Rectangle.Right, Rectangle.Bottom)));
}
@ -107,36 +126,45 @@ float sfView_GetCenterY(sfView* View)
////////////////////////////////////////////////////////////
/// Get the half-width of the view
/// Get the width of the view
////////////////////////////////////////////////////////////
float sfView_GetHalfSizeY(sfView* View)
float sfView_GetWidth(sfView* View)
{
CSFML_CHECK_RETURN(View, 0.f);
return View->This->GetHalfSize().x;
return View->This->GetSize().x;
}
////////////////////////////////////////////////////////////
/// Get the half-height of the view
/// Get the height of the view
////////////////////////////////////////////////////////////
float sfView_GetHalfSizeX(sfView* View)
float sfView_GetHeight(sfView* View)
{
CSFML_CHECK_RETURN(View, 0.f);
return View->This->GetHalfSize().y;
return View->This->GetSize().y;
}
////////////////////////////////////////////////////////////
/// Get the bounding rectangle of a view
/// Get the current rotation of a view
////////////////////////////////////////////////////////////
sfFloatRect sfView_GetRect(sfView* View)
float sfView_GetRotation(sfView* View)
{
CSFML_CALL_PTR_RETURN(View, GetRotation(), 0.f);
}
////////////////////////////////////////////////////////////
/// Get the target viewport of a view
////////////////////////////////////////////////////////////
sfFloatRect sfView_GetViewport(sfView* View)
{
sfFloatRect Rect = {0, 0, 0, 0};
CSFML_CHECK_RETURN(View, Rect);
sf::FloatRect SFMLRect = View->This->GetRect();
sf::FloatRect SFMLRect = View->This->GetViewport();
Rect.Left = SFMLRect.Left;
Rect.Top = SFMLRect.Top;
Rect.Right = SFMLRect.Right;
@ -155,6 +183,15 @@ void sfView_Move(sfView* View, float OffsetX, float OffsetY)
}
////////////////////////////////////////////////////////////
/// Rotate a view
////////////////////////////////////////////////////////////
void sfView_Rotate(sfView* View, float Angle)
{
CSFML_CALL_PTR(View, Rotate(Angle));
}
////////////////////////////////////////////////////////////
/// Resize a view rectangle to simulate a zoom / unzoom effect
////////////////////////////////////////////////////////////