See below for a minimal example. I've tried lots of variations of this code as well.
Nothing is drawn on the screen (except the green background color). If I instead create sprites from this same texture, I can draw those no problem.
If I add a white color to the vertices, and don't pass the RenderStates to Draw(), then it draws a white square of the expected size. So it seems to be just the texture association with the vertex array thats broken.
using SFML.Graphics;using SFML.System;using SFML.Window;namespace VAD
{ class Program
{ static void Main
(string[] args
) { VideoMode videoMode
= new VideoMode
(500,
500); RenderWindow window
= new RenderWindow
(videoMode,
"vertex arrays"); VertexArray va
= new VertexArray
(PrimitiveType
.Quads); Texture theTexture
= new Texture
(@"C:\pics\house.png"); RenderStates renderStates
= new RenderStates
(); renderStates
.Texture = theTexture
; va
.Append(new Vertex
(new Vector2f
(0,
0),
new Vector2f
(0,
0))); va
.Append(new Vertex
(new Vector2f
(500,
0),
new Vector2f
(100,
0))); va
.Append(new Vertex
(new Vector2f
(500,
500),
new Vector2f
(100,
100))); va
.Append(new Vertex
(new Vector2f
(0,
500),
new Vector2f
(0,
100))); while (true) { window
.DispatchEvents(); window
.Clear(Color
.Green); window
.Draw(va, renderStates
); window
.Display(); } } }}
This is C# obviously, using the SFML 2.5 nuget package. .NET6, Windows 10, Visual Studio 2022.
The issue isn't very obvious and stems from some constraints towards the CSFML interop.
The solution is, turning this
RenderStates renderStates
= new RenderStates
(); renderStates
.Texture = theTexture
;
into this
RenderStates renderStates
= new RenderStates
(theTexture
);