/// <summary> /// Create a SurfaceKHR object for a Wayland window. /// </summary> /// <param name="extendedHandle"> /// The Instance handle to extend. /// </param> /// <param name="flags"> /// Reserved for future use. /// </param> /// <param name="display"> /// display and surface are pointers to the Wayland wl_display and /// wl_surface to associate the surface with. /// </param> /// <param name="surface"> /// </param> /// <param name="allocator"> /// An optional AllocationCallbacks instance that controls host memory /// allocation. /// </param> public static unsafe SharpVk.Khronos.Surface CreateWaylandSurface(this SharpVk.Instance extendedHandle, IntPtr display, IntPtr surface, SharpVk.Khronos.WaylandSurfaceCreateFlags?flags = default(SharpVk.Khronos.WaylandSurfaceCreateFlags?), SharpVk.AllocationCallbacks?allocator = default(SharpVk.AllocationCallbacks?)) { try { SharpVk.Khronos.Surface result = default(SharpVk.Khronos.Surface); CommandCache commandCache = default(CommandCache); SharpVk.Interop.Khronos.WaylandSurfaceCreateInfo *marshalledCreateInfo = default(SharpVk.Interop.Khronos.WaylandSurfaceCreateInfo *); void *vkWaylandSurfaceCreateInfoKHRNextPointer = 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.WaylandSurfaceCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Khronos.WaylandSurfaceCreateInfo>()); marshalledCreateInfo->SType = StructureType.WaylandSurfaceCreateInfo; marshalledCreateInfo->Next = vkWaylandSurfaceCreateInfoKHRNextPointer; if (flags != null) { marshalledCreateInfo->Flags = flags.Value; } else { marshalledCreateInfo->Flags = default(SharpVk.Khronos.WaylandSurfaceCreateFlags); } marshalledCreateInfo->Display = (IntPtr *)(Interop.HeapUtil.Allocate <IntPtr>()); *marshalledCreateInfo->Display = display; marshalledCreateInfo->Surface = (IntPtr *)(Interop.HeapUtil.Allocate <IntPtr>()); *marshalledCreateInfo->Surface = surface; 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.VkInstanceCreateWaylandSurfaceDelegate commandDelegate = commandCache.Cache.vkCreateWaylandSurfaceKHR; 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(); } }
/// <summary> /// /// </summary> internal unsafe void MarshalTo(SharpVk.Interop.Khronos.WaylandSurfaceCreateInfo *pointer) { pointer->SType = StructureType.WaylandSurfaceCreateInfo; pointer->Next = null; if (this.Flags != null) { pointer->Flags = this.Flags.Value; } else { pointer->Flags = default(SharpVk.Khronos.WaylandSurfaceCreateFlags); } pointer->Display = this.Display; pointer->Surface = this.Surface; }