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

Author Topic: Problem with diagonal lines  (Read 6262 times)

0 Members and 1 Guest are viewing this topic.

Dominator

  • Newbie
  • *
  • Posts: 37
    • View Profile
Problem with diagonal lines
« on: November 14, 2009, 02:27:24 am »
Hi!

I'm using the latest SFML2-SVN with C# and encountered a problem when I tried to draw diagonal lines with Shape.Line().

It won't show the line when the thickness is set to 1.0f.
When I set it to 2.0f it's shown, but - like expected - double the size.

I tried to find a value that resembles 1.0f thickness, but it varies with the position and angle, so there is no safe way to get the right thickness.

If I for example want to draw a line from the upper left to the lower right corner of a 200x50 px rectangle, the line will look alright starting from a value of 1.03077f.


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Problem with diagonal lines
« Reply #1 on: November 14, 2009, 12:47:02 pm »
Interesting... I'll look into this issue as soon as possible.
Laurent Gomila - SFML developer

Dominator

  • Newbie
  • *
  • Posts: 37
    • View Profile
Problem with diagonal lines
« Reply #2 on: November 22, 2009, 01:46:17 pm »
Any progress so far?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Problem with diagonal lines
« Reply #3 on: November 22, 2009, 02:44:54 pm »
Yes. This is caused by the little piece of code that fixes rendering artifacts by rounding points coordinates. If you want a quick and dirty fix, I can tell you how to disable it.

I still haven't found a good and clean solution for this.
Laurent Gomila - SFML developer

Dominator

  • Newbie
  • *
  • Posts: 37
    • View Profile
Problem with diagonal lines
« Reply #4 on: November 22, 2009, 03:12:49 pm »
What kind of artifacts does it fix?
Is my program affected if I only use 2D stuff like Shape and String2D?

Do you think you can get this fixed in the near future?
Anyway, please tell me how to disable it.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Problem with diagonal lines
« Reply #5 on: November 22, 2009, 03:17:42 pm »
Quote
What kind of artifacts does it fix?

A lot, actually :)
It fixes all the unwanted pixels that may appear when a texel is not exactly mapped to a single pixel of the window.

Quote
Is my program affected if I only use 2D stuff like Shape and String2D?

Probably not.

Quote
Do you think you can get this fixed in the near future?

I have no idea how, but anyway I have no choice, this bug must be fixed ;)

Quote
Anyway, please tell me how to disable it.

In SFML (C++) source code, comment the lines 232 / 233 / 234 / 235 of the file src/SFML/Graphics/RenderQueue.cpp. Then recompiler everything (SFML, CSFML, SFML.Net).
Laurent Gomila - SFML developer

Dominator

  • Newbie
  • *
  • Posts: 37
    • View Profile
Problem with diagonal lines
« Reply #6 on: November 22, 2009, 03:26:13 pm »
Thanks! I can't see any artifacts (yet :wink: ) in my program, so it seems to work fine for me.

 

anything