sbarisic / NuklearDotNet

.NET binding for the Nuklear immediate mode GUI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong calling convention for delegates

kg opened this issue · comments

Your callback delegates are using the default calling convention, which does not always match the cdecl used by the actual dll.
They need to be

    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
	public delegate IntPtr nk_plugin_alloc_t(NkHandle handle, IntPtr old, IntPtr nk_size);
    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
	public delegate void nk_plugin_free_t(NkHandle handle, IntPtr old);
    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
	public delegate int nk_plugin_filter_t(ref nk_text_edit edit, uint unicode_rune);
    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
	public delegate void nk_plugin_paste_t(NkHandle handle, ref nk_text_edit edit);
    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
	public unsafe delegate void nk_plugin_copy_t(NkHandle handle, byte* str, int len);

Without this my app just terminates on return from callbacks during Init.

Thanks for reporting, i'll see if i can fix and update this to the latest nuklear version during this week if i have time.