Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to get the coordinates of a raw position of an object relative to the window  (Read 1786 times)

0 Members and 1 Guest are viewing this topic.

rogeriodec

  • Newbie
  • *
  • Posts: 42
    • View Profile
A rectangle shape is inside a view.
The view has been moved, zoomed, rotated, and the same for the rectangle.
But the rectangle is there in the window, visible.



I need to know the exact coordinate of this rectangle in relation to the window edges, ie how to grab a ruler and count the pixels of the visual object to the edges.
This has a purpose: I want to keep the object always visible in the window, regardless of which transformations it receives.

Does anyone know how to do this?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10821
    • View Profile
    • development blog
    • Email
Calculate/get the position of the object inside the view and then simply call mapCoordsToPixel on the window.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/