Hello, I am trying to find out how exactly View is working and I cannot seem to figure it out.
I looked at this page:
https://www.sfml-dev.org/tutorials/2.5/graphics-view.phpAnd wrote some test code:
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(1280, 720), "test");
sf::Event event;
sf::View view;
view.setViewport(sf::FloatRect(0.f, 0.f, 0.5f, 1.f));
window.setView(view);
sf::RectangleShape rs; rs.setSize({1280, 720});
while(window.isOpen())
{
while(window.pollEvent(event))
if(event.type == sf::Event::Closed)
window.close();
window.clear();
window.draw(rs);
window.display();
}
return 0;
}
The output:
What I expected:
Similar to this in the doc:
Can someone please explain what is happening?