/// <summary> /// Create a SurfaceKHR object for a X11 window, using the XCB /// client-side library. /// </summary> /// <param name="extendedHandle"> /// The Instance handle to extend. /// </param> /// <param name="flags"> /// Reserved for future use. /// </param> /// <param name="connection"> /// An xcb_connection_t to the X server. /// </param> /// <param name="window"> /// The xcb_window_t for the X11 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 CreateXcbSurface(this SharpVk.Instance extendedHandle, IntPtr connection, IntPtr window, SharpVk.Khronos.XcbSurfaceCreateFlags?flags = default(SharpVk.Khronos.XcbSurfaceCreateFlags?), SharpVk.AllocationCallbacks?allocator = default(SharpVk.AllocationCallbacks?)) { try { SharpVk.Khronos.Surface result = default(SharpVk.Khronos.Surface); CommandCache commandCache = default(CommandCache); SharpVk.Interop.Khronos.XcbSurfaceCreateInfo *marshalledCreateInfo = default(SharpVk.Interop.Khronos.XcbSurfaceCreateInfo *); void *nextPointer = 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.XcbSurfaceCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Khronos.XcbSurfaceCreateInfo>()); marshalledCreateInfo->SType = StructureType.XcbSurfaceCreateInfo; marshalledCreateInfo->Next = nextPointer; if (flags != null) { marshalledCreateInfo->Flags = flags.Value; } else { marshalledCreateInfo->Flags = default(SharpVk.Khronos.XcbSurfaceCreateFlags); } marshalledCreateInfo->Connection = (IntPtr *)(Interop.HeapUtil.Allocate <IntPtr>()); *marshalledCreateInfo->Connection = connection; marshalledCreateInfo->Window = window; 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.VkInstanceCreateXcbSurfaceDelegate commandDelegate = commandCache.GetCommandDelegate <SharpVk.Interop.Khronos.VkInstanceCreateXcbSurfaceDelegate>("vkCreateXcbSurfaceKHR", "instance"); 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.XcbSurfaceCreateInfo *pointer) { pointer->SType = StructureType.XcbSurfaceCreateInfo; pointer->Next = null; if (this.Flags != null) { pointer->Flags = this.Flags.Value; } else { pointer->Flags = default(SharpVk.Khronos.XcbSurfaceCreateFlags); } pointer->Connection = (IntPtr *)(Interop.HeapUtil.Allocate <IntPtr>()); *pointer->Connection = this.Connection; pointer->Window = this.Window; }