Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::Shape::Line displacement  (Read 1854 times)

0 Members and 1 Guest are viewing this topic.

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
sf::Shape::Line displacement
« 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::Shape::Line displacement
« Reply #1 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?
Laurent Gomila - SFML developer

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
sf::Shape::Line displacement
« Reply #2 on: October 15, 2010, 07:35:41 pm »
Ah sure, I might have guessed, thank you. :)

I'm using SFML2, like always.