Closed vvuk closed 2 years ago
A quick fix is to define:
public struct Handle {
public ushort value;
public Handle(ushort v) => this.value = v;
public static implicit operator ushort(Handle h) => h.value;
public static implicit operator Handle(ushort v) => new Handle(v);
}
in NativeMethods, and make all handle params/returns be of type Handle. With this and the implicit conversions, no other code needs to change (except for one place in Framebuffer.cs, depending on if you change the ushort*
to a Handle*
in the native method param).
The bgfx API has a lot of handle types that are passed as by-value structs, e.g.
SharpBgfx writes the DllImport like this:
This is incorrect -- whether the small struct that fits in a register is passed in the register, or still passed by pointer, is ABI-dependant. In particular, the Emscripten asmjs/wasm ABI always passes by pointer.