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

Author Topic: Window Viewport - Multiple Questions  (Read 1449 times)

0 Members and 1 Guest are viewing this topic.

computerquip

  • Newbie
  • *
  • Posts: 18
    • View Profile
Window Viewport - Multiple Questions
« on: December 13, 2011, 04:21:52 pm »
A view is a 2D rectangle of a scene which is plasted into a viewport, what you physically see (from what I understand anyways). I wrote an example: http://codepad.org/R9sAGQry (Yes, I know the Size class is redundant). It appears to draw correctly to the window, however resizing to smaller sizes seems to cause problems. Why is this?

Also, sf::Window::GetViewport returns IntRect where as sf::View::GetViewport returns FloatRect. Aren't they supposed to be the same thing?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Window Viewport - Multiple Questions
« Reply #1 on: December 13, 2011, 04:40:27 pm »
Quote
resizing to smaller sizes seems to cause problems. Why is this?

What problems?

In your code, when you write "Recalculate unit size", you're not recalculating anything, because you base your calculations on aView which is a constant vector that never changes. So I don't know what you want to do, but it's probably wrong ;)

Quote
Also, sf::Window::GetViewport returns IntRect where as sf::View::GetViewport returns FloatRect. Aren't they supposed to be the same thing?

If there are two functions, then they do different things. I try to avoid duplicating features in the public API.

sf::Window::GetViewport returns the viewport of the current view applied to the window, so it converts the normalized definition of the viewport (what sf::View::GetViewport returns) to pixels. Isn't it explained in the function's documentation?
Laurent Gomila - SFML developer