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

Author Topic: SFML wrapper - access violation on passing null shader to drawSprite()  (Read 8492 times)

0 Members and 1 Guest are viewing this topic.

Enok

  • Newbie
  • *
  • Posts: 16
    • View Profile
Solved. It was a mismatch between the backing enum types for sf::BlendMode::Factor vs my beef representation, the correct type was uint32.

Hey! I'm currently doing SFML bindings in the beef programming language and I've run into a bit of a problem when trying to call sfRenderWindow_drawSprite() and passing in RenderStates with a null shader handle.

ShaderHandle & TextureHandle are just pointer-sized opaque handles

[CRepr, Ordered]
public struct RenderStates
{
    public BlendMode Mode;
    public Matrix3x3 Matrix; //sfTransform
    public TextureHandle TextureH;
    public ShaderHandle ShaderH;

   public this(BlendMode mode, Texture texture, Shade shader, Matrix3x3? matrix)
   {
        Mode = mode;
        TextureH = texture.[Friend]_handle;
        ShaderH = shader.[Friend]_handle;
        Matrix = matrix ?? Matrix3x3.Identity;  
   }
}

public static void Main()
{
        using(let window = new RenderWindow(VideoMode(800, 600), "Title")) {
                window.ClosedEvent.Add(scope (w) => {
                        window.Close();
                });

                var texture = scope Texture("resources/beef.png");
                var sprite = scope Sprite(texture);
                var renderStates = RenderStates(BlendMode.Alpha, texture, null, null);

                while (window.IsOpen())
                {
                        window.ClearColor(Color.CornflowerBlue);
                        window.DispatchEvents();
                        //window.DrawSprite(sprite, renderStates); ACCESS VIOLATION
                        window.Display();
                }
        }
}
 
« Last Edit: May 07, 2020, 08:48:10 pm by Enok »

 

anything