public VeldridImGuiWindow(GraphicsDevice gd, ImGuiViewportPtr vp) { _gcHandle = GCHandle.Alloc(this); _gd = gd; _vp = vp; SDL_WindowFlags flags = SDL_WindowFlags.Hidden; if ((vp.Flags & ImGuiViewportFlags.NoTaskBarIcon) != 0) { flags |= SDL_WindowFlags.SkipTaskbar; } if ((vp.Flags & ImGuiViewportFlags.NoDecoration) != 0) { flags |= SDL_WindowFlags.Borderless; } else { flags |= SDL_WindowFlags.Resizable; } if ((vp.Flags & ImGuiViewportFlags.TopMost) != 0) { flags |= SDL_WindowFlags.AlwaysOnTop; } _window = new Sdl2Window( "No Title Yet", (int)vp.Pos.X, (int)vp.Pos.Y, (int)vp.Size.X, (int)vp.Size.Y, flags, false); _window.Resized += () => _vp.PlatformRequestResize = true; _window.Moved += p => _vp.PlatformRequestMove = true; _window.Closed += () => _vp.PlatformRequestClose = true; SwapchainSource scSource = VeldridStartup.GetSwapchainSource(_window); SwapchainDescription scDesc = new SwapchainDescription(scSource, (uint)_window.Width, (uint)_window.Height, null, true, false); _sc = _gd.ResourceFactory.CreateSwapchain(scDesc); _window.Resized += () => _sc.Resize((uint)_window.Width, (uint)_window.Height); unsafe { ViewportDataPtr data = new ViewportDataPtr(Marshal.AllocHGlobal(Unsafe.SizeOf <ViewportDataPtr>())); vp.PlatformUserData = new HandleRef(data, (IntPtr)data.NativePtr).Handle; } vp.PlatformUserData = (IntPtr)_gcHandle; }
/// <summary> /// Creates a new <see cref="Swapchain"/>. /// </summary> /// <param name="description">The desired properties of the created object.</param> /// <returns>A new <see cref="Swapchain"/>.</returns> public abstract Swapchain CreateSwapchain(ref SwapchainDescription description);
/// <summary> /// Creates a new <see cref="Swapchain"/>. /// </summary> /// <param name="description">The desired properties of the created object.</param> /// <returns>A new <see cref="Swapchain"/>.</returns> public Swapchain CreateSwapchain(SwapchainDescription description) => CreateSwapchain(ref description);