I've created a very simple app that renders a square with size 200:
sf::RectangleShape rectangle;
rectangle.setSize(sf::Vector2f(200, 200));
rectangle.setFillColor(sf::Color::Magenta);
rectangle.setPosition(10, 10);
window.draw(rectangle);
The square is rendered correctly. However, when the window is resized, the square is deformed into a rectangle and the size is reduced or increased according to the size of the window. Perhaps it's my misunderstanding and size and position are related to the window size? Is that correct? How could I create a shape with a specific size (and the same in height and width)?
I'm using the SFML v2.0 available at http://www.sfml-dev.org/download.php (not the latest version in Git).
Thanks. It works. I've used the following code:
if (event.type == sf::Event::Resized) {
window.setView(sf::View(sf::FloatRect(0, 0, event.size.width, event.size.height)));
}
I will look into the View class. However, I cannot understand why it is required. I guess that the normal situation should be that the whole window corresponds to a view unless it is modified by the developer.