SFML community forums

Help => Graphics => Topic started by: dabo on May 26, 2008, 09:11:01 pm

Title: SetCenter() blurs my text sometimes
Post by: dabo on May 26, 2008, 09:11:01 pm
Is this just happening to me? When I give the method mentioned in the subject "float" parameters sometimes the text gets blurry. For example:

Code: [Select]
Text.SetCenter(TextRect.GetWidth() / 2, 0.f);

Doing this fixes it:

Code: [Select]
Text.SetCenter((int) TextRect.GetWidth() / 2, 0.f);

I find it strange that this method takes "float" parameters if I must use (int) conversion in order to make sure I don't get blurry text.
Title: SetCenter() blurs my text sometimes
Post by: Laurent on May 27, 2008, 06:09:50 pm
Is it happening only when the width is an odd number ?
Title: SetCenter() blurs my text sometimes
Post by: dabo on May 28, 2008, 12:15:04 pm
This for example makes my text blurry:

Code: [Select]
Text.SetCenter(31.5f, 0.f);

This doesn't:

Code: [Select]
Text.SetCenter(31.f, 0.f);
Title: SetCenter() blurs my text sometimes
Post by: Laurent on May 28, 2008, 02:58:49 pm
Ok I see. I guess it's related to the way half-pixels are rasterized, and in this case we can't help much. The easiest solution for you is to use integer coordinates.

If you wonder why SFML uses float coordinates, it's because those coordinates are not pixels, they are view units. So you could have a view covering the entire window but which is only 1 unit long ;)
Title: SetCenter() blurs my text sometimes
Post by: dabo on May 28, 2008, 05:51:26 pm
Quote from: "Laurent"
Ok I see. I guess it's related to the way half-pixels are rasterized, and in this case we can't help much. The easiest solution for you is to use integer coordinates.

If you wonder why SFML uses float coordinates, it's because those coordinates are not pixels, they are view units. So you could have a view covering the entire window but which is only 1 unit long ;)


Ok, thanks. It's not a big problem for me, I'm fine using the int conversion.