Applied the sf::Rect modifications in CSFML and SFML.Net
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1504 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
082a928555
commit
fb91bf4c6d
12 changed files with 99 additions and 193 deletions
|
@ -39,30 +39,18 @@ typedef struct
|
|||
{
|
||||
float Left;
|
||||
float Top;
|
||||
float Right;
|
||||
float Bottom;
|
||||
float Width;
|
||||
float Height;
|
||||
} sfFloatRect;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int Left;
|
||||
int Top;
|
||||
int Right;
|
||||
int Bottom;
|
||||
int Width;
|
||||
int Height;
|
||||
} sfIntRect;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Move a rectangle by the given offset
|
||||
///
|
||||
/// \param rect : Rectangle to move
|
||||
/// \param offsetX : Horizontal offset
|
||||
/// \param offsetY : Vertical offset
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
CSFML_API void sfFloatRect_Offset(sfFloatRect* rect, float offsetX, float offsetY);
|
||||
CSFML_API void sfIntRect_Offset(sfIntRect* rect, int offsetX, int offsetY);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Check if a point is inside a rectangle's area
|
||||
///
|
||||
|
|
|
@ -95,12 +95,12 @@ sfGlyph sfFont_GetGlyph(sfFont* font, sfUint32 codePoint, unsigned int character
|
|||
glyph.Advance = SFMLGlyph.Advance;
|
||||
glyph.Bounds.Left = SFMLGlyph.Bounds.Left;
|
||||
glyph.Bounds.Top = SFMLGlyph.Bounds.Top;
|
||||
glyph.Bounds.Right = SFMLGlyph.Bounds.Right;
|
||||
glyph.Bounds.Bottom = SFMLGlyph.Bounds.Bottom;
|
||||
glyph.Bounds.Width = SFMLGlyph.Bounds.Width;
|
||||
glyph.Bounds.Height = SFMLGlyph.Bounds.Height;
|
||||
glyph.SubRect.Left = SFMLGlyph.SubRect.Left;
|
||||
glyph.SubRect.Top = SFMLGlyph.SubRect.Top;
|
||||
glyph.SubRect.Right = SFMLGlyph.SubRect.Right;
|
||||
glyph.SubRect.Bottom = SFMLGlyph.SubRect.Bottom;
|
||||
glyph.SubRect.Width = SFMLGlyph.SubRect.Width;
|
||||
glyph.SubRect.Height = SFMLGlyph.SubRect.Height;
|
||||
|
||||
return glyph;
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ void sfImage_CreateMaskFromColor(sfImage* image, sfColor colorKey, sfUint8 alpha
|
|||
void sfImage_CopyImage(sfImage* image, const sfImage* source, unsigned int destX, unsigned int destY, sfIntRect sourceRect)
|
||||
{
|
||||
CSFML_CHECK(source);
|
||||
sf::IntRect SFMLRect(sourceRect.Left, sourceRect.Top, sourceRect.Right, sourceRect.Bottom);
|
||||
sf::IntRect SFMLRect(sourceRect.Left, sourceRect.Top, sourceRect.Width, sourceRect.Height);
|
||||
CSFML_CALL_PTR(image, Copy(*source->This, destX, destY, SFMLRect));
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ void sfImage_CopyImage(sfImage* image, const sfImage* source, unsigned int destX
|
|||
CSFML_API sfBool sfImage_CopyScreen(sfImage* image, sfRenderWindow* window, sfIntRect sourceRect)
|
||||
{
|
||||
CSFML_CHECK_RETURN(window, sfFalse);
|
||||
sf::IntRect SFMLRect(sourceRect.Left, sourceRect.Top, sourceRect.Right, sourceRect.Bottom);
|
||||
sf::IntRect SFMLRect(sourceRect.Left, sourceRect.Top, sourceRect.Width, sourceRect.Height);
|
||||
CSFML_CALL_PTR_RETURN(image, CopyScreen(window->This, SFMLRect), sfFalse);
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,7 @@ const sfUint8* sfImage_GetPixelsPtr(const sfImage* image)
|
|||
////////////////////////////////////////////////////////////
|
||||
void sfImage_UpdatePixels(const sfImage* image, const sfUint8* pixels, sfIntRect rectangle)
|
||||
{
|
||||
sf::IntRect rect(rectangle.Left, rectangle.Top, rectangle.Right, rectangle.Bottom);
|
||||
sf::IntRect rect(rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height);
|
||||
CSFML_CALL_PTR(image, UpdatePixels(pixels, rect));
|
||||
}
|
||||
|
||||
|
|
|
@ -30,39 +30,18 @@
|
|||
#include <SFML/Internal.h>
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Move a rectangle by the given offset
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfFloatRect_Offset(sfFloatRect* rect, float offsetX, float offsetY)
|
||||
{
|
||||
CSFML_CHECK(rect)
|
||||
rect->Left += offsetX;
|
||||
rect->Right += offsetX;
|
||||
rect->Top += offsetY;
|
||||
rect->Bottom += offsetY;
|
||||
}
|
||||
void sfIntRect_Offset(sfIntRect* rect, int offsetX, int offsetY)
|
||||
{
|
||||
CSFML_CHECK(rect)
|
||||
rect->Left += offsetX;
|
||||
rect->Right += offsetX;
|
||||
rect->Top += offsetY;
|
||||
rect->Bottom += offsetY;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// Check if a point is inside a rectangle's area
|
||||
////////////////////////////////////////////////////////////
|
||||
sfBool sfFloatRect_Contains(const sfFloatRect* rect, float x, float y)
|
||||
{
|
||||
CSFML_CHECK_RETURN(rect, sfFalse)
|
||||
return sf::FloatRect(rect->Left, rect->Top, rect->Right, rect->Bottom).Contains(x, y);
|
||||
return sf::FloatRect(rect->Left, rect->Top, rect->Width, rect->Height).Contains(x, y);
|
||||
}
|
||||
sfBool sfIntRect_Contains(const sfIntRect* rect, int x, int y)
|
||||
{
|
||||
CSFML_CHECK_RETURN(rect, sfFalse)
|
||||
return sf::IntRect(rect->Left, rect->Top, rect->Right, rect->Bottom).Contains(x, y);
|
||||
return sf::IntRect(rect->Left, rect->Top, rect->Width, rect->Height).Contains(x, y);
|
||||
}
|
||||
|
||||
|
||||
|
@ -74,8 +53,8 @@ sfBool sfFloatRect_Intersects(const sfFloatRect* rect1, const sfFloatRect* rect2
|
|||
CSFML_CHECK_RETURN(rect1, sfFalse)
|
||||
CSFML_CHECK_RETURN(rect2, sfFalse)
|
||||
|
||||
sf::FloatRect SFMLRect1(rect1->Left, rect1->Top, rect1->Right, rect1->Bottom);
|
||||
sf::FloatRect SFMLRect2(rect2->Left, rect2->Top, rect2->Right, rect2->Bottom);
|
||||
sf::FloatRect SFMLRect1(rect1->Left, rect1->Top, rect1->Width, rect1->Height);
|
||||
sf::FloatRect SFMLRect2(rect2->Left, rect2->Top, rect2->Width, rect2->Height);
|
||||
|
||||
if (intersection)
|
||||
{
|
||||
|
@ -84,8 +63,8 @@ sfBool sfFloatRect_Intersects(const sfFloatRect* rect1, const sfFloatRect* rect2
|
|||
|
||||
intersection->Left = overlap.Left;
|
||||
intersection->Top = overlap.Top;
|
||||
intersection->Right = overlap.Right;
|
||||
intersection->Bottom = overlap.Bottom;
|
||||
intersection->Width = overlap.Width;
|
||||
intersection->Height = overlap.Height;
|
||||
|
||||
return intersects;
|
||||
}
|
||||
|
@ -99,8 +78,8 @@ sfBool sfIntRect_Intersects(const sfIntRect* rect1, const sfIntRect* rect2, sfIn
|
|||
CSFML_CHECK_RETURN(rect1, sfFalse)
|
||||
CSFML_CHECK_RETURN(rect2, sfFalse)
|
||||
|
||||
sf::IntRect SFMLRect1(rect1->Left, rect1->Top, rect1->Right, rect1->Bottom);
|
||||
sf::IntRect SFMLRect2(rect2->Left, rect2->Top, rect2->Right, rect2->Bottom);
|
||||
sf::IntRect SFMLRect1(rect1->Left, rect1->Top, rect1->Width, rect1->Height);
|
||||
sf::IntRect SFMLRect2(rect2->Left, rect2->Top, rect2->Width, rect2->Height);
|
||||
|
||||
if (intersection)
|
||||
{
|
||||
|
@ -109,8 +88,8 @@ sfBool sfIntRect_Intersects(const sfIntRect* rect1, const sfIntRect* rect2, sfIn
|
|||
|
||||
intersection->Left = overlap.Left;
|
||||
intersection->Top = overlap.Top;
|
||||
intersection->Right = overlap.Right;
|
||||
intersection->Bottom = overlap.Bottom;
|
||||
intersection->Width = overlap.Width;
|
||||
intersection->Height = overlap.Height;
|
||||
|
||||
return intersects;
|
||||
}
|
||||
|
|
|
@ -212,8 +212,8 @@ sfIntRect sfRenderImage_GetViewport(const sfRenderImage* renderImage, const sfVi
|
|||
sf::IntRect SFMLrect = renderImage->This.GetViewport(view->This);
|
||||
rect.Left = SFMLrect.Left;
|
||||
rect.Top = SFMLrect.Top;
|
||||
rect.Right = SFMLrect.Right;
|
||||
rect.Bottom = SFMLrect.Bottom;
|
||||
rect.Width = SFMLrect.Width;
|
||||
rect.Height = SFMLrect.Height;
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
|
|
@ -449,8 +449,8 @@ sfIntRect sfRenderWindow_GetViewport(const sfRenderWindow* renderWindow, const s
|
|||
sf::IntRect SFMLrect = renderWindow->This.GetViewport(view->This);
|
||||
rect.Left = SFMLrect.Left;
|
||||
rect.Top = SFMLrect.Top;
|
||||
rect.Right = SFMLrect.Right;
|
||||
rect.Bottom = SFMLrect.Bottom;
|
||||
rect.Width = SFMLrect.Width;
|
||||
rect.Height = SFMLrect.Height;
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
|
|
@ -41,8 +41,8 @@ sfSprite* sfSprite_Create()
|
|||
sprite->Image = NULL;
|
||||
sprite->SubRect.Left = sprite->This.GetSubRect().Left;
|
||||
sprite->SubRect.Top = sprite->This.GetSubRect().Top;
|
||||
sprite->SubRect.Right = sprite->This.GetSubRect().Right;
|
||||
sprite->SubRect.Bottom = sprite->This.GetSubRect().Bottom;
|
||||
sprite->SubRect.Width = sprite->This.GetSubRect().Width;
|
||||
sprite->SubRect.Height = sprite->This.GetSubRect().Height;
|
||||
|
||||
return sprite;
|
||||
}
|
||||
|
@ -319,7 +319,7 @@ void sfSprite_SetImage(sfSprite* sprite, const sfImage* image, sfBool adjustToNe
|
|||
////////////////////////////////////////////////////////////
|
||||
void sfSprite_SetSubRect(sfSprite* sprite, sfIntRect rectangle)
|
||||
{
|
||||
CSFML_CALL(sprite, SetSubRect(sf::IntRect(rectangle.Left, rectangle.Top, rectangle.Right, rectangle.Bottom)))
|
||||
CSFML_CALL(sprite, SetSubRect(sf::IntRect(rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height)))
|
||||
sprite->SubRect = rectangle;
|
||||
}
|
||||
|
||||
|
|
|
@ -425,8 +425,8 @@ sfFloatRect sfText_GetRect(const sfText* text)
|
|||
sf::FloatRect SFMLRect = text->This.GetRect();
|
||||
text->Rect.Left = SFMLRect.Left;
|
||||
text->Rect.Top = SFMLRect.Top;
|
||||
text->Rect.Right = SFMLRect.Right;
|
||||
text->Rect.Bottom = SFMLRect.Bottom;
|
||||
text->Rect.Width = SFMLRect.Width;
|
||||
text->Rect.Height = SFMLRect.Height;
|
||||
|
||||
return text->Rect;
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ void sfView_SetRotation(sfView* view, float angle)
|
|||
////////////////////////////////////////////////////////////
|
||||
void sfView_SetViewport(sfView* view, sfFloatRect viewport)
|
||||
{
|
||||
CSFML_CALL(view, SetViewport(sf::FloatRect(viewport.Left, viewport.Top, viewport.Right, viewport.Bottom)));
|
||||
CSFML_CALL(view, SetViewport(sf::FloatRect(viewport.Left, viewport.Top, viewport.Width, viewport.Height)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -113,7 +113,7 @@ void sfView_SetViewport(sfView* view, sfFloatRect viewport)
|
|||
////////////////////////////////////////////////////////////
|
||||
void sfView_Reset(sfView* view, sfFloatRect rectangle)
|
||||
{
|
||||
CSFML_CALL(view, Reset(sf::FloatRect(rectangle.Left, rectangle.Top, rectangle.Right, rectangle.Bottom)));
|
||||
CSFML_CALL(view, Reset(sf::FloatRect(rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -181,8 +181,8 @@ sfFloatRect sfView_GetViewport(const sfView* view)
|
|||
sf::FloatRect SFMLRect = view->This.GetViewport();
|
||||
rect.Left = SFMLRect.Left;
|
||||
rect.Top = SFMLRect.Top;
|
||||
rect.Right = SFMLRect.Right;
|
||||
rect.Bottom = SFMLRect.Bottom;
|
||||
rect.Width = SFMLRect.Width;
|
||||
rect.Height = SFMLRect.Height;
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
|
|
@ -32,10 +32,8 @@ EXPORTS
|
|||
sfImage_GetWidth
|
||||
sfImage_GetHeight
|
||||
sfImage_IsSmooth
|
||||
sfFloatRect_Offset
|
||||
sfFloatRect_Contains
|
||||
sfFloatRect_Intersects
|
||||
sfIntRect_Offset
|
||||
sfIntRect_Contains
|
||||
sfIntRect_Intersects
|
||||
sfShader_CreateFromFile
|
||||
|
|
|
@ -32,10 +32,8 @@ EXPORTS
|
|||
sfImage_GetWidth
|
||||
sfImage_GetHeight
|
||||
sfImage_IsSmooth
|
||||
sfFloatRect_Offset
|
||||
sfFloatRect_Contains
|
||||
sfFloatRect_Intersects
|
||||
sfIntRect_Offset
|
||||
sfIntRect_Contains
|
||||
sfIntRect_Intersects
|
||||
sfShader_CreateFromFile
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue