1
General / SFML wrapper - access violation on passing null shader to drawSprite()
« on: May 07, 2020, 12:24:23 pm »
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
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();
}
}
}
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();
}
}
}