mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-26 13:06:13 +01:00
Updated RenderTarget::convertCoords
This commit is contained in:
1 parent
bdaa4974ac
commit
228a06ba64
4 files changed
+28
-24
No files matched your search
@@ -141,18 +141,21 @@ sfIntRect sfRenderTexture_getViewport(const sfRenderTexture* renderTexture, cons
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfRenderTexture_convertCoords(const sfRenderTexture* renderTexture, unsigned int textureX, unsigned int textureY, float* viewX, float* viewY, const sfView* targetView)
|
||||
sfVector2f sfRenderTexture_convertCoords(const sfRenderTexture* renderTexture, sfVector2i point, const sfView* targetView)
|
||||
{
|
||||
CSFML_CHECK(renderTexture);
|
||||
sfVector2f result = {0, 0};
|
||||
CSFML_CHECK_RETURN(renderWindow, result);
|
||||
|
||||
sf::Vector2f point;
|
||||
sf::Vector2f sfmlPoint;
|
||||
if (targetView)
|
||||
point = renderTexture->This.convertCoords(textureX, textureY, targetView->This);
|
||||
sfmlPoint = renderTexture->This.convertCoords(sf::Vector2i(point.x, point.y), targetView->This);
|
||||
else
|
||||
point = renderTexture->This.convertCoords(textureX, textureY);
|
||||
sfmlPoint = renderTexture->This.convertCoords(sf::Vector2i(point.x, point.y));
|
||||
|
||||
if (viewX) *viewX = point.x;
|
||||
if (viewY) *viewY = point.y;
|
||||
result.x = sfmlPoint.x;
|
||||
result.y = sfmlPoint.y;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -346,18 +346,21 @@ sfIntRect sfRenderWindow_getViewport(const sfRenderWindow* renderWindow, const s
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void sfRenderWindow_convertCoords(const sfRenderWindow* renderWindow, unsigned int windowX, unsigned int windowY, float* viewX, float* viewY, const sfView* targetView)
|
||||
sfVector2f sfRenderWindow_convertCoords(const sfRenderWindow* renderWindow, sfVector2i point, const sfView* targetView)
|
||||
{
|
||||
CSFML_CHECK(renderWindow);
|
||||
sfVector2f result = {0, 0};
|
||||
CSFML_CHECK_RETURN(renderWindow, result);
|
||||
|
||||
sf::Vector2f point;
|
||||
sf::Vector2f sfmlPoint;
|
||||
if (targetView)
|
||||
point = renderWindow->This.convertCoords(windowX, windowY, targetView->This);
|
||||
sfmlPoint = renderWindow->This.convertCoords(sf::Vector2i(point.x, point.y), targetView->This);
|
||||
else
|
||||
point = renderWindow->This.convertCoords(windowX, windowY);
|
||||
sfmlPoint = renderWindow->This.convertCoords(sf::Vector2i(point.x, point.y));
|
||||
|
||||
if (viewX) *viewX = point.x;
|
||||
if (viewY) *viewY = point.y;
|
||||
result.x = sfmlPoint.x;
|
||||
result.y = sfmlPoint.y;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user