Hello everyone!
I tried using sf::View with the example of the tutorials but it seems that using sf::RenderWindow::setView doesn't work with me. If I use it, i can't display the red quare as I want in the following code, I only get a black window:
#include<SFML/Graphics.hpp>
int main()
{
sf::RectangleShape rect (sf::Vector2f(100,100));
rect.setFillColor(sf::Color::Red);
sf::RenderWindow window (sf::VideoMode(1000,800), "ViewTest");
// Initialize the view to a rectangle located at (100, 100) and with a size of 400x200
sf::View view (sf::FloatRect(100, 100, 400, 200));
// Apply it
window.setView(view);
// Render stuff
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(rect);
window.display();
}
return 0;
}