「.NET for AndroidでSurfaceViewのANativeWindowを取得する」の版間の差分

提供:MonoBook
ページの作成:「.NET for Android(旧:Xamarin.Android)でVulkanを動かすのにSurfaceViewのANativeWindowを取得する必要がある。.NETだとANativeWindow_fromSurface…」
 
編集の要約なし
1行目: 1行目:
.NET for Android(旧:Xamarin.Android)で[[Vulkan]]を動かすのにSurfaceViewのANativeWindowを取得する必要がある。.NETだとANativeWindow_fromSurfaceをP/Invokeで簡単に呼び出せるのが便利。
.NET for Android(旧:Xamarin.Android)で[[Vulkan]]を動かすのにSurfaceViewのANativeWindowを取得する必要がある。.NETだとANativeWindow_fromSurfaceをP/Invokeで簡単に呼び出せるのが便利。


<source lnag="csharp">
<source lang="csharp">
[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);

2024年4月23日 (火) 05:29時点における版

.NET for Android(旧:Xamarin.Android)でVulkanを動かすのにSurfaceViewのANativeWindowを取得する必要がある。.NETだとANativeWindow_fromSurfaceをP/Invokeで簡単に呼び出せるのが便利。

[DllImport("android", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ANativeWindow_fromSurface(IntPtr env, IntPtr surface);

public static ANativeWindowFromSurfaceView(SurfaceView surfaceView) {
    Surface surface = surfaceView.Holder.Surface;
    IntPtr surfacePtr = JNIEnv.ToLocalJniHandle(surface);
    IntPtr aNativeWindow = ANativeWindow_fromSurface(JNIEnv.Handle, surfacePtr);
    return aNativeWindow;
}