SFML community forums
Help => Graphics => Topic started by: cpolymeris on July 09, 2013, 09:11:12 am
-
(http://i.imgur.com/VAsGqPV.png)
EDIT: Fixed broken image link
In the above image, the nice colorful rectangle near the center is generated by a VertexArray, while the ugly triangle to the left is generated by a Vertex[]. I would have expected them to be the same. Here's the code:
using SFML.Graphics;using SFML.Window;public class TestProgram
{ private RenderWindow window
; static void Main
() { RenderWindow window
= new RenderWindow
(new VideoMode
(800,
600),
"VA test"); window
.SetVerticalSyncEnabled(true); window
.Closed += (sender, e
) => window
.Close(); Vertex v1
= new Vertex
(new Vector2f
(300,
100), Color
.White); Vertex v2
= new Vertex
(new Vector2f
(450,
100), Color
.Green); Vertex v3
= new Vertex
(new Vector2f
(450,
300), Color
.Magenta); Vertex v4
= new Vertex
(new Vector2f
(300,
300), Color
.Yellow); VertexArray vertexArray
= new VertexArray
(PrimitiveType
.Quads,
4); vertexArray
.Append(v1
); vertexArray
.Append(v2
); vertexArray
.Append(v3
); vertexArray
.Append(v4
); Vertex
[] arrayOfVertices
= new Vertex
[64]; arrayOfVertices
[0] = v1
; arrayOfVertices
[1] = v2
; arrayOfVertices
[2] = v3
; arrayOfVertices
[3] = v4
; while (window
.IsOpen()) { window
.DispatchEvents(); window
.Clear(); window
.Draw(vertexArray
); window
.Draw(arrayOfVertices,
0,
4, PrimitiveType
.Quads); window
.Display(); } window
.Dispose(); }}
Note, the bug is also present if you use other PrimitiveTypes. I am not sure if this is a bug in SFML, in SFML.Net or I just don't know how to use RenderWindow.Draw(Vertex[], ...).
c.f. the issue in Gwen.Net that lead me to this (http://code.google.com/p/gwen-dotnet/issues/detail?id=29)
-
Your image link is broken.
Your code looks ok, this may be a bug in SFML.Net. I'll investigate it and let you know what I find.
-
Your code works perfectly for me. Which version of SFML.Net do you use?
-
Fixed the image link.
Your code works perfectly for me. Which version of SFML.Net do you use?
git 033cec2f7..., i.e. HEAD~1
-
And are you sure that you're using the corresponding CSFML DLLs, and not an old version?
-
And are you sure that you're using the corresponding CSFML DLLs, and not an old version?
Honestly, no.
I think I was using the latest CSFML (.so, not DLL) and SFML versions, but since the problem wasn't present in my Windows install (which uses the "stable" CSFML release from this website), I tried downgrading to see if it would fix this issue. Which it didn't.
Then couldn't upgrade again (that SFML_DIR issue, "#$%&/ cmake >:(), so I ended up installing the development versions from Jonathan's repo (https://launchpad.net/~sonkun), which says it's been last updated "Tue, 23 Apr 2013 17:51:22 +0100".
Anyways, I have modified GWEN.Net to use VertexArray instead of Vertex[] (http://code.google.com/p/gwen-dotnet/issues/detail?id=29) and it works for me, now. It could potentially be slower, but I don't want to spend that much time chasing SFML bugs I am not even sure exist, I have a game to write! :D