.NET for Android(旧:Xamarin.Android)で[[Vulkan]]を動かすのにSurfaceViewのANativeWindowを取得する必要がある。.NETだとANativeWindow_fromSurfaceをP/Invokeで簡単に呼び出せるのが便利。を動かすのにSurfaceViewのANativeWindowを取得する必要があった。
以下でうまくいった。.NETだとANativeWindow_fromSurfaceをP/Invokeで簡単に呼び出せるのが便利。 <source lnaglang="csharp">
[DllImport("android", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ANativeWindow_fromSurface(IntPtr env, IntPtr surface);
public static ANativeWindowFromSurfaceViewIntPtr GetANativeWindowFromSurfaceView(SurfaceView surfaceView) {
Surface surface = surfaceView.Holder.Surface;
IntPtr surfacePtr = JNIEnv.ToLocalJniHandle(surface);
}
</source>
[[category: .NET for Android]]