mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-27 13:36:12 +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
@@ -140,14 +140,13 @@ CSFML_GRAPHICS_API sfIntRect sfRenderTexture_getViewport(const sfRenderTexture*
|
|||||||
/// \brief Convert a point in texture coordinates into view coordinates
|
/// \brief Convert a point in texture coordinates into view coordinates
|
||||||
///
|
///
|
||||||
/// \param renderTexture Render texture object
|
/// \param renderTexture Render texture object
|
||||||
/// \param windowX X coordinate of the point to convert, relative to the texture
|
/// \param point Point to convert, relative to the texture
|
||||||
/// \param windowY Y coordinate of the point to convert, relative to the texture
|
|
||||||
/// \param viewX Pointer to fill with the X coordinate of the converted point
|
|
||||||
/// \param viewY Pointer to fill with the Y coordinate of the converted point
|
|
||||||
/// \param targetView Target view to convert the point to (pass NULL to use the current view)
|
/// \param targetView Target view to convert the point to (pass NULL to use the current view)
|
||||||
///
|
///
|
||||||
|
/// \return The converted point, in "world" units
|
||||||
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CSFML_GRAPHICS_API void sfRenderTexture_convertCoords(const sfRenderTexture* renderTexture, unsigned int windowX, unsigned int windowY, float* viewX, float* viewY, const sfView* targetView);
|
CSFML_GRAPHICS_API sfVector2f sfRenderTexture_convertCoords(const sfRenderTexture* renderTexture, sfVector2i point, const sfView* targetView);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Draw a drawable object to the render-target
|
/// \brief Draw a drawable object to the render-target
|
||||||
|
|||||||
@@ -316,14 +316,13 @@ CSFML_GRAPHICS_API sfIntRect sfRenderWindow_getViewport(const sfRenderWindow* re
|
|||||||
/// \brief Convert a point in window coordinates into view coordinates
|
/// \brief Convert a point in window coordinates into view coordinates
|
||||||
///
|
///
|
||||||
/// \param renderWindow Render window object
|
/// \param renderWindow Render window object
|
||||||
/// \param windowX X coordinate of the point to convert, relative to the window
|
/// \param point Point to convert, relative to the window
|
||||||
/// \param windowY Y coordinate of the point to convert, relative to the window
|
|
||||||
/// \param viewX Pointer to fill with the X coordinate of the converted point
|
|
||||||
/// \param viewY Pointer to fill with the Y coordinate of the converted point
|
|
||||||
/// \param targetView Target view to convert the point to (pass NULL to use the current view)
|
/// \param targetView Target view to convert the point to (pass NULL to use the current view)
|
||||||
///
|
///
|
||||||
|
/// \return The converted point, in "world" units
|
||||||
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CSFML_GRAPHICS_API void sfRenderWindow_convertCoords(const sfRenderWindow* renderWindow, unsigned int windowX, unsigned int windowY, float* viewX, float* viewY, const sfView* targetView);
|
CSFML_GRAPHICS_API sfVector2f sfRenderWindow_convertCoords(const sfRenderWindow* renderWindow, sfVector2i point, const sfView* targetView);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Draw a drawable object to the render-target
|
/// \brief Draw a drawable object to the render-target
|
||||||
|
|||||||
@@ -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)
|
if (targetView)
|
||||||
point = renderTexture->This.convertCoords(textureX, textureY, targetView->This);
|
sfmlPoint = renderTexture->This.convertCoords(sf::Vector2i(point.x, point.y), targetView->This);
|
||||||
else
|
else
|
||||||
point = renderTexture->This.convertCoords(textureX, textureY);
|
sfmlPoint = renderTexture->This.convertCoords(sf::Vector2i(point.x, point.y));
|
||||||
|
|
||||||
if (viewX) *viewX = point.x;
|
result.x = sfmlPoint.x;
|
||||||
if (viewY) *viewY = point.y;
|
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)
|
if (targetView)
|
||||||
point = renderWindow->This.convertCoords(windowX, windowY, targetView->This);
|
sfmlPoint = renderWindow->This.convertCoords(sf::Vector2i(point.x, point.y), targetView->This);
|
||||||
else
|
else
|
||||||
point = renderWindow->This.convertCoords(windowX, windowY);
|
sfmlPoint = renderWindow->This.convertCoords(sf::Vector2i(point.x, point.y));
|
||||||
|
|
||||||
if (viewX) *viewX = point.x;
|
result.x = sfmlPoint.x;
|
||||||
if (viewY) *viewY = point.y;
|
result.y = sfmlPoint.y;
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user