Forms resize proportionally using a window in SFML 2.X
The code is outside the tutorial on the SFML site. When I compile and run it, the circle scales proportionally when the window is scaled by the user. I want the circle to remain the same.
When the screen is resized, both the correct screen dimensions and the correct circle radius are printed to the console, but the way the circle is drawn on the screen is definitely not what it claims. The circle is not visually distorted in any way, but it looks like it is being drawn with a different set of values โโrelative to what is printed on the console.
antialiasingLevel
has nothing to do with the dawn of form, if that helps.
#include <iostream>
#include <SFML/Graphics.hpp>
int main()
{
sf::ContextSettings settings;
settings.antialiasingLevel = 8;
sf::RenderWindow window(sf::VideoMode(200, 200), "Title", sf::Style::Default, settings);
sf::CircleShape shape(100);
shape.setFillColor(sf::Color::Green);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
else if (event.type == sf::Event::Resized)
{
std::cout << "resize: (" << event.size.width << ',' << event.size.height << ") -> " << shape.getRadius() << std::endl;
}
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
+3
source to share