SFML community forums

Help => General => Topic started by: computerquip on December 13, 2011, 04:21:52 pm

Title: Window Viewport - Multiple Questions
Post by: computerquip 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?
Title: Window Viewport - Multiple Questions
Post by: Laurent 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?