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

Author Topic: sfml 2.0 window.convertCoords(curPosMouse) - why?  (Read 4864 times)

0 Members and 1 Guest are viewing this topic.

leanid.chaika

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
sfml 2.0 window.convertCoords(curPosMouse) - why?
« on: June 16, 2012, 10:09:22 am »
I just intresting in OOP decision why window.convertCoords(curPosMouse) not view.convertCoords(curPosMouse) ?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: sfml 2.0 window.convertCoords(curPosMouse) - why?
« Reply #1 on: June 16, 2012, 10:38:22 am »
convertCoords convert coordinates from the render target perspectiv to the view perspectiv, i.e. the function needs two parameters. Furthermore the function is declared within sf::RenderTarget so it applies automatically to sf::RenderWindow and sf::RenderTexture.

Now if you'd put it on the view itself you would always have to specify which render target it should convert the coordinates from. If you put it on the render target itself you just need to specify the coordinates and optinal you can give another sf::View as the one that render target is working with.

Also I'm not sure what kinda of internal stuff the function needs from the render target. If uses some private variables then you can't really put it onto the view otherwise you would need to expose private stuff so it could be accessed from the view.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sfml 2.0 window.convertCoords(curPosMouse) - why?
« Reply #2 on: June 16, 2012, 11:47:19 am »
convertCoords needs a render target (= the source coordinate system) and a view (= the target coordinate system). So it could be in both classes. But since sf::View doesn't know about sf::RenderTarget, and sf::RenderTarget already has a dependency to sf::View, it's more natural to do it this way.
Laurent Gomila - SFML developer

Jeffrey

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: sfml 2.0 window.convertCoords(curPosMouse) - why?
« Reply #3 on: July 29, 2012, 06:02:55 am »
Why, since all the coordinates are made in sf::Vector2f, does convertCoords() accept sf::Vector2i?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: sfml 2.0 window.convertCoords(curPosMouse) - why?
« Reply #4 on: July 29, 2012, 07:56:54 am »
Because pixel coordinates of the window are defined precisly, i.e. there are no half pixel coordinates. The sf::Mouse::getPosition() also returns a sf::Vector2i.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/