/// <summary> /// /// </summary> internal unsafe void MarshalTo(SharpVk.Interop.Khronos.Win32SurfaceCreateInfo *pointer) { pointer->SType = StructureType.Win32SurfaceCreateInfo; pointer->Next = null; if (this.Flags != null) { pointer->Flags = this.Flags.Value; } else { pointer->Flags = default(SharpVk.Khronos.Win32SurfaceCreateFlags); } pointer->Hinstance = this.Hinstance; pointer->Hwnd = this.Hwnd; }
/// <summary> /// Create a SurfaceKHR object for an Win32 native window. /// </summary> /// <param name="extendedHandle"> /// The Instance handle to extend. /// </param> /// <param name="flags"> /// Reserved for future use. /// </param> /// <param name="hinstance"> /// Win32 HINSTANCE for the window to associate the surface with. /// </param> /// <param name="hwnd"> /// Win32 HWND for the window to associate the surface with. /// </param> /// <param name="allocator"> /// An optional AllocationCallbacks instance that controls host memory /// allocation. /// </param> public static unsafe SharpVk.Khronos.Surface CreateWin32Surface(this SharpVk.Instance extendedHandle, IntPtr hinstance, IntPtr hwnd, SharpVk.Khronos.Win32SurfaceCreateFlags?flags = default(SharpVk.Khronos.Win32SurfaceCreateFlags?), SharpVk.AllocationCallbacks?allocator = default(SharpVk.AllocationCallbacks?)) { try { SharpVk.Khronos.Surface result = default(SharpVk.Khronos.Surface); CommandCache commandCache = default(CommandCache); SharpVk.Interop.Khronos.Win32SurfaceCreateInfo *marshalledCreateInfo = default(SharpVk.Interop.Khronos.Win32SurfaceCreateInfo *); void *vkWin32SurfaceCreateInfoKHRNextPointer = default(void *); SharpVk.Interop.AllocationCallbacks *marshalledAllocator = default(SharpVk.Interop.AllocationCallbacks *); SharpVk.Interop.Khronos.Surface marshalledSurface = default(SharpVk.Interop.Khronos.Surface); commandCache = extendedHandle.commandCache; marshalledCreateInfo = (SharpVk.Interop.Khronos.Win32SurfaceCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Khronos.Win32SurfaceCreateInfo>()); marshalledCreateInfo->SType = StructureType.Win32SurfaceCreateInfo; marshalledCreateInfo->Next = vkWin32SurfaceCreateInfoKHRNextPointer; if (flags != null) { marshalledCreateInfo->Flags = flags.Value; } else { marshalledCreateInfo->Flags = default(SharpVk.Khronos.Win32SurfaceCreateFlags); } marshalledCreateInfo->Hinstance = hinstance; marshalledCreateInfo->Hwnd = hwnd; if (allocator != null) { marshalledAllocator = (SharpVk.Interop.AllocationCallbacks *)(Interop.HeapUtil.Allocate <SharpVk.Interop.AllocationCallbacks>()); allocator.Value.MarshalTo(marshalledAllocator); } else { marshalledAllocator = default(SharpVk.Interop.AllocationCallbacks *); } SharpVk.Interop.Khronos.VkInstanceCreateWin32SurfaceDelegate commandDelegate = commandCache.Cache.vkCreateWin32SurfaceKHR; Result methodResult = commandDelegate(extendedHandle.handle, marshalledCreateInfo, marshalledAllocator, &marshalledSurface); if (SharpVkException.IsError(methodResult)) { throw SharpVkException.Create(methodResult); } result = new SharpVk.Khronos.Surface(extendedHandle, marshalledSurface); return(result); } finally { Interop.HeapUtil.FreeAll(); } }