SFML community forums

Help => General => Topic started by: Xrey274 on March 09, 2019, 06:19:57 pm

Title: Text gets blurry when resizing window.
Post by: Xrey274 on March 09, 2019, 06:19:57 pm
Whenever I resize the window the text gets blurred. I even made a "text update" function, but that doesn't seem to matter.
Title: Re: Text gets blurry when resizing window.
Post by: Laurent on March 09, 2019, 06:25:20 pm
Yes, that's because everything gets scaled. You can adjust the view to the new size of the window if you don't want this to happen.
Title: Re: Text gets blurry when resizing window.
Post by: Xrey274 on March 10, 2019, 11:18:46 pm
I did this but still blurry, even after updating the text manually.

window.setView(sf::View(sf::FloatRect(0, 0, event.size.width, event.size.height)));

    width = windowWidth;
    height = windowHeight;

    changeBrushText.setString("Change Brush");
    changeBrushText.setFont(font);
    changeBrushText.setCharacterSize(width / 96);
    changeBrushText.setFillColor(sf::Color(210, 210, 210));
    changeBrushText.setPosition(((width / 10) - changeBrushText.getLocalBounds().width) / 2,((height / 27  ) - changeBrushText.getLocalBounds().height) / 2);

Title: Re: Text gets blurry when resizing window.
Post by: Laurent on March 11, 2019, 07:59:56 am
Round the coordinates that you pass to setPosition. See here (https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Transformable.php#details) for more details.
Title: Re: Text gets blurry when resizing window.
Post by: Xrey274 on March 11, 2019, 06:17:55 pm
That was it - thanks! Why does the function .setPosition() even take in floats?
Title: Re: Text gets blurry when resizing window.
Post by: Laurent on March 11, 2019, 06:36:12 pm
You should know why, if you read the link I posted ;)