private unsafe void CreateSurface()
        {
            // Check for Window Handle parameter
            if (Description.DeviceWindowHandle == null)
            {
                throw new ArgumentException("DeviceWindowHandle cannot be null");
            }
            // Create surface
#if XENKO_UI_SDL
            var control = Description.DeviceWindowHandle.NativeWindow as SDL.Window;
            SDL2.SDL.SDL_Vulkan_CreateSurface(control.SdlHandle, GraphicsDevice.NativeInstance.NativeHandle, out IntPtr surfacePtr);
            surface = new Surface(surfacePtr);
#elif XENKO_PLATFORM_WINDOWS
            var controlHandle = Description.DeviceWindowHandle.Handle;
            if (controlHandle == IntPtr.Zero)
            {
                throw new NotSupportedException($"Form of type [{Description.DeviceWindowHandle.GetType().Name}] is not supported. Only System.Windows.Control are supported");
            }

            var surfaceCreateInfo = new Win32SurfaceCreateInfo
            {
                StructureType  = StructureType.Win32SurfaceCreateInfo,
                InstanceHandle = Process.GetCurrentProcess().Handle,
                WindowHandle   = controlHandle,
            };
            surface = GraphicsDevice.NativeInstance.CreateWin32Surface(surfaceCreateInfo);
#elif XENKO_PLATFORM_ANDROID
            throw new NotImplementedException();
#elif XENKO_PLATFORM_LINUX
            throw new NotSupportedException("Only SDL is supported for the time being on Linux");
#else
            throw new NotSupportedException();
#endif
        }
Esempio n. 2
0
        protected virtual void CreateSurface()
        {
            var surfaceCreateInfo = new Win32SurfaceCreateInfo
            {
                StructureType  = StructureType.Win32SurfaceCreateInfo,
                InstanceHandle = Process.GetCurrentProcess().Handle,
                WindowHandle   = form.Handle,
            };

            surface = instance.CreateWin32Surface(surfaceCreateInfo);
        }
Esempio n. 3
0
        static void CreateSurface()
        {
            IntPtr HINSTANCE, HWND;

            GetProcessHandles(out HINSTANCE, out HWND);
            var surfaceCreateInfo = new Win32SurfaceCreateInfo
            {
                hinstance = HINSTANCE,
                hwnd      = HWND,
            };

            surface = instance.CreateWin32Surface(surfaceCreateInfo);
            Console.WriteLine("[ OK ] Surface");
        }
Esempio n. 4
0
        public static unsafe ReturnSet <Surface> Create(Instance instance, Form form)
        {
            try
            {
                var surfaceCreateInfo = new Win32SurfaceCreateInfo
                {
                    StructureType  = StructureType.Win32SurfaceCreateInfo,
                    InstanceHandle = Process.GetCurrentProcess().Handle,
                    WindowHandle   = form.Handle,
                };

                return(new ReturnSet <Surface>(instance.CreateWin32Surface(surfaceCreateInfo)));
            }
            catch (Exception ex)
            {
                return(new ReturnSet <Surface>(ex));
            }
        }
        private unsafe void CreateSurface()
        {
            // Check for Window Handle parameter
            if (Description.DeviceWindowHandle == null)
            {
                throw new ArgumentException("DeviceWindowHandle cannot be null");
            }
            // Create surface
#if SILICONSTUDIO_PLATFORM_WINDOWS
            var controlHandle = Description.DeviceWindowHandle.Handle;
            if (controlHandle == IntPtr.Zero)
            {
                throw new NotSupportedException($"Form of type [{Description.DeviceWindowHandle.GetType().Name}] is not supported. Only System.Windows.Control are supported");
            }

            var surfaceCreateInfo = new Win32SurfaceCreateInfo
            {
                StructureType = StructureType.Win32SurfaceCreateInfo,
#if !SILICONSTUDIO_RUNTIME_CORECLR
                InstanceHandle = Process.GetCurrentProcess().Handle,
#else
                // To implement for CoreCLR, currently passing a NULL pointer seems to work
                InstanceHandle = IntPtr.Zero,
#endif
                WindowHandle = controlHandle,
            };
            surface = GraphicsDevice.NativeInstance.CreateWin32Surface(surfaceCreateInfo);
#elif SILICONSTUDIO_PLATFORM_ANDROID
            throw new NotImplementedException();
#elif SILICONSTUDIO_PLATFORM_LINUX
#if SILICONSTUDIO_XENKO_UI_SDL
            var control = Description.DeviceWindowHandle.NativeWindow as SDL.Window;
            if (control == null)
            {
                throw new NotSupportedException("Non SDL Window used in SDL setup.");
            }

            if (GraphicsAdapterFactory.GetInstance(GraphicsDevice.IsDebugMode).HasXlibSurfaceSupport)
            {
                var createInfo = new XlibSurfaceCreateInfo
                {
                    StructureType = StructureType.XlibSurfaceCreateInfo,
                    Window = checked((uint)control.Handle), // On Linux, a Window identifier is 32-bit
                    Dpy = control.Display,
                };
                surface =GraphicsDevice.NativeInstance.CreateXlibSurface(ref createInfo);
            }
            else
            {
                var createInfo = new XcbSurfaceCreateInfo()
                {
                    StructureType = StructureType.XcbSurfaceCreateInfo,
                    Window = checked((uint)control.Handle), // On Linux, a Window identifier is 32-bit
                    Connection = control.XcbConnection,
                };
                surface = GraphicsDevice.NativeInstance.CreateXcbSurface(ref createInfo);
            }
#else
            throw new NotSupportedException("Only SDL is supported for the time being on Linux");
#endif
#else
            throw new NotSupportedException();
#endif
        }
Esempio n. 6
0
 protected virtual void CreateSurface()
 {
     var surfaceCreateInfo = new Win32SurfaceCreateInfo
     {
         StructureType = StructureType.Win32SurfaceCreateInfo,
         InstanceHandle = Process.GetCurrentProcess().Handle,
         WindowHandle = form.Handle,
     };
     surface = instance.CreateWin32Surface(surfaceCreateInfo);
 }
        private unsafe void CreateSurface()
        {
            // Check for Window Handle parameter
            if (Description.DeviceWindowHandle == null)
            {
                throw new ArgumentException("DeviceWindowHandle cannot be null");
            }
            // Create surface
#if XENKO_PLATFORM_WINDOWS
            var controlHandle = Description.DeviceWindowHandle.Handle;
            if (controlHandle == IntPtr.Zero)
            {
                throw new NotSupportedException($"Form of type [{Description.DeviceWindowHandle.GetType().Name}] is not supported. Only System.Windows.Control are supported");
            }

            var surfaceCreateInfo = new Win32SurfaceCreateInfo
            {
                StructureType = StructureType.Win32SurfaceCreateInfo,
#if !XENKO_RUNTIME_CORECLR
                InstanceHandle = Process.GetCurrentProcess().Handle,
#else
                // To implement for CoreCLR, currently passing a NULL pointer seems to work
                InstanceHandle = IntPtr.Zero,
#endif
                WindowHandle = controlHandle,
            };
            surface = GraphicsDevice.NativeInstance.CreateWin32Surface(surfaceCreateInfo);
#elif XENKO_PLATFORM_ANDROID
            throw new NotImplementedException();
#elif XENKO_PLATFORM_LINUX
#if XENKO_UI_SDL
            var control = Description.DeviceWindowHandle.NativeWindow as SDL.Window;
            if (control == null)
            {
                throw new NotSupportedException("Non SDL Window used in SDL setup.");
            }

            if (GraphicsAdapterFactory.GetInstance(GraphicsDevice.IsDebugMode).HasXlibSurfaceSupport)
            {
                var createInfo = new XlibSurfaceCreateInfo
                {
                    StructureType = StructureType.XlibSurfaceCreateInfo,
                    Window        = checked ((uint)control.Handle), // On Linux, a Window identifier is 32-bit
                    Dpy           = control.Display,
                };
                surface = GraphicsDevice.NativeInstance.CreateXlibSurface(ref createInfo);
            }
            else
            {
                var createInfo = new XcbSurfaceCreateInfo()
                {
                    StructureType = StructureType.XcbSurfaceCreateInfo,
                    Window        = checked ((uint)control.Handle), // On Linux, a Window identifier is 32-bit
                    Connection    = control.XcbConnection,
                };
                surface = GraphicsDevice.NativeInstance.CreateXcbSurface(ref createInfo);
            }
#else
            throw new NotSupportedException("Only SDL is supported for the time being on Linux");
#endif
#else
            throw new NotSupportedException();
#endif
        }
Esempio n. 8
0
 internal static unsafe extern Result vkCreateWin32SurfaceKHR(Instance instance, Win32SurfaceCreateInfo* createInfo, AllocationCallbacks* allocator, Surface* surface);
Esempio n. 9
0
 public unsafe Surface CreateWin32Surface(Win32SurfaceCreateInfo createInfo, AllocationCallbacks* allocator = null)
 {
     Surface surface;
     vkCreateWin32SurfaceKHR(this, &createInfo, allocator, &surface).CheckError();
     return surface;
 }