Now I have explained all the data types that were transcribed to C# but the problem still lies in creating the correct definition of the mpv_render_context_create and calling it.
First I tried to define the method like this:
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]private static extern int mpv_render_context_create([Out] out IntPtr renderContext, IntPtr mpvHandle, MpvRenderParam[] parameters);
var ptr = IntPtr.Zero;var apiTypePtr = Marshal.StringToHGlobalAuto("opengl");var i = mpv_render_context_create(out ptr, _mpvHandle, new []{ new MpvRenderParam(MpvRenderParamType.ApiType, apiTypePtr), new MpvRenderParam(MpvRenderParamType.Invalid, IntPtr.Zero});
I also tried changing the first parameter to be a ref or IntPtr but no matter what combination of parameter type and calling it, I always got the same exception:
Exception thrown at 0x0000000055C73D60 (mpv-1.dll) in Otchi.App.exe: 0xC0000005: Access violation reading location 0x0000000000000010.
My last attempt was going into the unsafe part of C# and declaring the method like this:
IntPtr ptr;var test = GCHandle.Alloc("opengl");var test2 = GCHandle.ToIntPtr(test);var apiTypePtr = Marshal.StringToHGlobalAuto("opengl");var i = mpv_render_context_create(&ptr, _mpvHandle, new []{ new MpvRenderParam{Type = MpvRenderParamType.ApiType, Data = &apiTypePtr}, new MpvRenderParam{Type = MpvRenderParamType.Invalid, Data = null}});
Thanks for your reply, however, in the example they use the "wid" approach, where they just embed the video. This is not what i'm looking for, I want to render the video myself into a SharpGL context. I have taken many of the DllImports from the example you have provided, however the method I am having trouble with, is not part of the examples.
Can you have a look at the following sample:
https://github.com/mpv-player/mpv-examples/tree/master/libmpv/csharp