polytronicgr / gwen-dotnet

Automatically exported from code.google.com/p/gwen-dotnet
0 stars 0 forks source link

SFML renderer broken #29

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Run UnitTest
2. sfFont is null

Reverting the changes made to SFML.cs in r102 and removing the "mono bug 
workaround" in the same file fixes the sfFont being null and another issue, but 
the rendering is still broken. See attached screenshot.

What version of the product are you using? On what operating system?
trunk, on Linux

Is the SFML renderer not up to date? What is the recommended renderer? I am 
using the latest SFML, SFML.Net and CSFML.

Original issue reported on code.google.com by cpolymeris on 8 Jul 2013 at 12:39

Attachments:

GoogleCodeExporter commented 8 years ago
I have now tested this with older SFML releases (the official stable ones on 
the site) and it still doesn't work, but in a slightly different way (see 
attachment). The windows version works. (with "stable" sfml versions, haven't 
tested the ones from the git repo)
If I can be of help, please let me know. I am quite frustrated with the lack of 
a C# gui that works with SFML, and am trying to move away from GTK.

Original comment by cpolymeris on 8 Jul 2013 at 7:46

Attachments:

GoogleCodeExporter commented 8 years ago
I have been looking into this a bit and have discovered what might be the root 
of the issue: SFML's RenderWindow.Draw(Vertex[], ...) function seems to be 
broken or behaving in a non-intuitive way. In particular, the following code 
outputs the attached drawing, the colorful rectangle (the correct one) being 
the one drawn with VertexArray, and the weird triangle the one drawn with 
Vertex[]:

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();
    }
}

Original comment by cpolymeris on 9 Jul 2013 at 7:04

Attachments:

GoogleCodeExporter commented 8 years ago
I could probably try to figure out what the SFML bug is (if there is one), but 
I am too lazy. Instead I have just modified GWEN.Net to use VertexArray 
instead. It might (or not) be less efficient than the original implementation, 
but at least it works perfectly!
If someone else needs it, see attached patch. The font bug is also fixed.

Note that the original file has CR+LF line endings, while I am using LF. If 
that causes issues for you, convert either the original file or my patch.

Original comment by cpolymeris on 9 Jul 2013 at 5:10

Attachments: