「.NET for AndroidでSurfaceViewのANativeWindowを取得する」を編集中
ナビゲーションに移動
検索に移動
この編集を取り消せます。 下記の差分を確認して、本当に取り消していいか検証してください。よろしければ変更を保存して取り消しを完了してください。
最新版 | 編集中の文章 | ||
1行目: | 1行目: | ||
− | .NET for Android(旧:Xamarin.Android)で[[Vulkan]] | + | .NET for Android(旧:Xamarin.Android)で[[Vulkan]]を動かすのにSurfaceViewのANativeWindowを取得する必要がある。.NETだとANativeWindow_fromSurfaceをP/Invokeで簡単に呼び出せるのが便利。 |
− | + | <source lnag="csharp"> | |
− | |||
− | |||
− | <source | ||
[DllImport("android", CallingConvention = CallingConvention.Cdecl)] | [DllImport("android", CallingConvention = CallingConvention.Cdecl)] | ||
public static extern IntPtr ANativeWindow_fromSurface(IntPtr env, IntPtr surface); | public static extern IntPtr ANativeWindow_fromSurface(IntPtr env, IntPtr surface); | ||
− | public static | + | public static ANativeWindowFromSurfaceView(SurfaceView surfaceView) { |
Surface surface = surfaceView.Holder.Surface; | Surface surface = surfaceView.Holder.Surface; | ||
IntPtr surfacePtr = JNIEnv.ToLocalJniHandle(surface); | IntPtr surfacePtr = JNIEnv.ToLocalJniHandle(surface); | ||
15行目: | 12行目: | ||
} | } | ||
</source> | </source> | ||
+ | |||
[[category: .NET for Android]] | [[category: .NET for Android]] |