SFML community forums

Bindings - other languages => DotNet => Topic started by: Dominator on November 14, 2009, 02:27:24 am

Title: Problem with diagonal lines
Post by: Dominator 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.

(http://i34.tinypic.com/2n7i9p1.jpg)
Title: Problem with diagonal lines
Post by: Laurent on November 14, 2009, 12:47:02 pm
Interesting... I'll look into this issue as soon as possible.
Title: Problem with diagonal lines
Post by: Dominator on November 22, 2009, 01:46:17 pm
Any progress so far?
Title: Problem with diagonal lines
Post by: Laurent 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.
Title: Problem with diagonal lines
Post by: Dominator 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.
Title: Problem with diagonal lines
Post by: Laurent 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).
Title: Problem with diagonal lines
Post by: Dominator 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.