SFML community forums

Help => Graphics => Topic started by: Tank on October 15, 2010, 05:09:28 pm

Title: sf::Shape::Line displacement
Post by: Tank on October 15, 2010, 05:09:28 pm
Hi guys, hey Laurent,

just discovered that sf::Shape::Line() procudes a line with wrong coordinates. I constructed an sf::Shape like this:

Code: [Select]
sf::Shape  line( sf::Shape::Line( 0.f, 0.f, 0.f, 100.f, 1.f, sf::Color( 255, 255, 0 ) );

Didn't see anything. ;) Then I moved it by one unit to the right and it appeared.

I remember I had that problem once with sf::Shape::Rectangle(), too. But when I wanted to reproduce it when I found the problem described above, everything seemed to work just fine.
Title: sf::Shape::Line displacement
Post by: Laurent on October 15, 2010, 06:24:00 pm
With 1 pixel lines you should never use integer coordinates, otherwise your line is located between the centers of two adjacent pixels and the rasterization rules can make it disappear -- or not, because rounding floating point numbers is not an exact science ;)

If I'm right, you should be able to see the line if you do one of the following things:
- increase its thickness (e.g. 1.1)
- move it to x = 0.5
- draw a Shape::Rectangle at the same coordinates

By the way, are you using SFML 1 or 2?
Title: sf::Shape::Line displacement
Post by: Tank on October 15, 2010, 07:35:41 pm
Ah sure, I might have guessed, thank you. :)

I'm using SFML2, like always.