Ejemplo n.º 1
0
        public Swapchain CreateSwapchain()
        {
            Swapchain swapchain;

            if (Widget.Backend == GraphicsBackend.OpenGL)
            {
                swapchain = Widget.GraphicsDevice.MainSwapchain;
            }
            else
            {
                // To embed Veldrid in an Eto control, these platform-specific
                // versions of CreateSwapchain use the technique outlined here:
                //
                //   https://github.com/mellinoe/veldrid/issues/155
                //
                var source = SwapchainSource.CreateXlib(
                    X11Interop.gdk_x11_display_get_xdisplay(Control.Display.Handle),
                    X11Interop.gdk_x11_window_get_xid(Control.Window.Handle));

                var renderSize = RenderSize;
                swapchain = Widget.GraphicsDevice.ResourceFactory.CreateSwapchain(
                    new SwapchainDescription(
                        source,
                        (uint)renderSize.Width,
                        (uint)renderSize.Height,
                        Widget.GraphicsDeviceOptions.SwapchainDepthFormat,
                        Widget.GraphicsDeviceOptions.SyncToVerticalBlank,
                        Widget.GraphicsDeviceOptions.SwapchainSrgbFormat));
            }

            return(swapchain);
        }
Ejemplo n.º 2
0
        public IWindowInfo UpdateWindowInfo(GraphicsMode mode)
        {
            WindowInfo?.Dispose();

            IntPtr display = X11Interop.gdk_x11_display_get_xdisplay(Display.Handle);
            int    screen  = X11Interop.gdk_x11_screen_get_screen_number(Screen.Handle);

            IntPtr visualInfo;

            if (mode.Index.HasValue)
            {
                var template = new X11Interop.XVisualInfo {
                    VisualID = mode.Index.Value
                };

                visualInfo = X11Interop.XGetVisualInfo(display, (IntPtr)(int)X11Interop.XVisualInfoMask.ID, ref template, out _);
            }
            else
            {
                visualInfo = X11Interop.GetVisualInfo(display, screen);
            }

            WindowInfo = Utilities.CreateX11WindowInfo(
                display,
                screen,
#if GTK3
                X11Interop.gdk_x11_window_get_xid(Window.Handle),
                X11Interop.gdk_x11_window_get_xid(Screen.RootWindow.Handle),
#else
                X11Interop.gdk_x11_drawable_get_xid(GdkWindow.Handle),
                X11Interop.gdk_x11_drawable_get_xid(RootWindow.Handle),
#endif
                visualInfo);

            X11Interop.XFree(visualInfo);

            WindowInfoUpdated?.Invoke(this, EventArgs.Empty);

            return(WindowInfo);
        }
Ejemplo n.º 3
0
 IntPtr VeldridSurface.IOpenGL.GetProcAddress(string name) => X11Interop.glXGetProcAddress(name);