Beispiel #1
0
        public unsafe SurfaceKHR CreateSurface(VulkanInstance instance)
        {
            if (OperatingSystem.IsWindows())
            {
                if (instance.Api.TryGetInstanceExtension(new Instance(instance.Handle), out KhrWin32Surface surfaceExtension))
                {
                    var createInfo = new Win32SurfaceCreateInfoKHR()
                    {
                        Hinstance = 0, Hwnd = Handle, SType = StructureType.Win32SurfaceCreateInfoKhr
                    };

                    surfaceExtension.CreateWin32Surface(new Instance(instance.Handle), createInfo, null, out var surface).ThrowOnError();

                    return(surface);
                }
            }
            else if (OperatingSystem.IsLinux())
            {
                if (instance.Api.TryGetInstanceExtension(new Instance(instance.Handle), out KhrXlibSurface surfaceExtension))
                {
                    var createInfo = new XlibSurfaceCreateInfoKHR()
                    {
                        SType  = StructureType.XlibSurfaceCreateInfoKhr,
                        Dpy    = (nint *)Display,
                        Window = Handle
                    };

                    surfaceExtension.CreateXlibSurface(new Instance(instance.Handle), createInfo, null, out var surface).ThrowOnError();

                    return(surface);
                }
            }

            throw new PlatformNotSupportedException("The current platform does not support surface creation.");
        }
Beispiel #2
0
        public unsafe SurfaceKHR CreateWin32Surface(Device device, Instance instance, Vk vk)
        {
            vk.TryGetInstanceExtension(instance, out KhrWin32Surface khrSurface);

            var createInfo = new Win32SurfaceCreateInfoKHR()
            {
                SType     = StructureType.Win32SurfaceCreateInfoKhr,
                Hinstance = 0,
                Hwnd      = win32Window
            };

            khrSurface.CreateWin32Surface(instance, createInfo, null, out var surface);

            return(surface);
        }
Beispiel #3
0
        void CreatePresentationSurface()
        {
            IntPtr hwnd      = window.Handle;
            IntPtr hinstance = Marshal.GetHINSTANCE(typeof(VulkanCommon).Module);

            Win32SurfaceCreateInfoKHR surface_create_info = new Win32SurfaceCreateInfoKHR
            {
                sType     = StructureType.Win32SurfaceCreateInfoKhr,             // VkStructureType                  sType
                pNext     = IntPtr.Zero,                                         // const void                      *pNext
                flags     = 0,                                                   // VkWin32SurfaceCreateFlagBitsKHR     flags
                hinstance = hinstance,                                           // HINSTANCE                        hinstance
                hwnd      = hwnd                                                 // HWND                             hwnd
            };

            khrW32surface.CreateWin32SurfaceKHR(vulkan.Instance, ref surface_create_info, (AllocationCallbacks *)0, out vulkan.PresentationSurface).CheckError();
        }
        SurfaceKHR CreateWin32Surface(Instance instance, IntPtr formHandle)
        {
            var surfaceCreateInfo = new Win32SurfaceCreateInfoKHR(Process.GetCurrentProcess().Handle, formHandle);

            return(instance.CreateWin32SurfaceKHR(surfaceCreateInfo));
        }
 public abstract Result CreateWin32Surface([Count(Count = 0)] Instance instance, [Count(Count = 0), Flow(FlowDirection.In)] ref Win32SurfaceCreateInfoKHR pCreateInfo, [Count(Count = 0), Flow(FlowDirection.In)] ref AllocationCallbacks pAllocator, [Count(Count = 0), Flow(FlowDirection.Out)] out SurfaceKHR pSurface);