コード例 #1
0
 /// <summary>
 /// Constructs a new SwapchainDescription.
 /// </summary>
 /// <param name="source">The <see cref="SwapchainSource"/> which will be used as the target of rendering operations.
 /// This is a window-system-specific object which differs by platform.</param>
 /// <param name="width">The initial width of the Swapchain surface.</param>
 /// <param name="height">The initial height of the Swapchain surface.</param>
 /// <param name="depthFormat">The optional format of the depth target of the Swapchain's Framebuffer.
 /// If non-null, this must be a valid depth Texture format.
 /// If null, then no depth target will be created.</param>
 /// <param name="syncToVerticalBlank">Indicates whether presentation of the Swapchain will be synchronized to the window
 /// system's vertical refresh rate.</param>
 public SwapchainDescription(SwapchainSource source, uint width, uint height, PixelFormat?depthFormat, bool syncToVerticalBlank)
 {
     Source              = source;
     Width               = width;
     Height              = height;
     DepthFormat         = depthFormat;
     SyncToVerticalBlank = syncToVerticalBlank;
 }
コード例 #2
0
        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;
        }