示例#1
0
 /// <summary>
 /// Create a SurfaceKHR object for an X11 window, using the Xlib
 /// client-side library.
 /// </summary>
 /// <param name="extendedHandle">
 /// The Instance handle to extend.
 /// </param>
 /// <param name="flags">
 /// Reserved for future use.
 /// </param>
 /// <param name="dpy">
 /// An Xlib Display connection to the X server.
 /// </param>
 /// <param name="window">
 /// An Xlib 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 CreateXlibSurface(this SharpVk.Instance extendedHandle, IntPtr dpy, IntPtr window, SharpVk.Khronos.XlibSurfaceCreateFlags?flags = default(SharpVk.Khronos.XlibSurfaceCreateFlags?), SharpVk.AllocationCallbacks?allocator = default(SharpVk.AllocationCallbacks?))
 {
     try
     {
         SharpVk.Khronos.Surface result       = default(SharpVk.Khronos.Surface);
         CommandCache            commandCache = default(CommandCache);
         SharpVk.Interop.Khronos.XlibSurfaceCreateInfo *marshalledCreateInfo = default(SharpVk.Interop.Khronos.XlibSurfaceCreateInfo *);
         void *vkXlibSurfaceCreateInfoKHRNextPointer = 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.XlibSurfaceCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Khronos.XlibSurfaceCreateInfo>());
         marshalledCreateInfo->SType = StructureType.XlibSurfaceCreateInfo;
         marshalledCreateInfo->Next  = vkXlibSurfaceCreateInfoKHRNextPointer;
         if (flags != null)
         {
             marshalledCreateInfo->Flags = flags.Value;
         }
         else
         {
             marshalledCreateInfo->Flags = default(SharpVk.Khronos.XlibSurfaceCreateFlags);
         }
         marshalledCreateInfo->Dpy = (IntPtr *)(Interop.HeapUtil.Allocate <IntPtr>());
         *marshalledCreateInfo->Dpy = dpy;
         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.VkInstanceCreateXlibSurfaceDelegate commandDelegate = commandCache.Cache.vkCreateXlibSurfaceKHR;
         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();
     }
 }
示例#2
0
 /// <summary>
 ///
 /// </summary>
 internal unsafe void MarshalTo(SharpVk.Interop.Khronos.XlibSurfaceCreateInfo *pointer)
 {
     pointer->SType = StructureType.XlibSurfaceCreateInfo;
     pointer->Next  = null;
     if (this.Flags != null)
     {
         pointer->Flags = this.Flags.Value;
     }
     else
     {
         pointer->Flags = default(SharpVk.Khronos.XlibSurfaceCreateFlags);
     }
     pointer->Dpy = (IntPtr *)(Interop.HeapUtil.Allocate <IntPtr>());
     *pointer->Dpy = this.Dpy;
     pointer->Window = this.Window;
 }