コード例 #1
0
 public static bool GetKey(KeyCode keyCode)
 {
     return(GLFW.GetKey(Game.Game.Window.Handle, (int)keyCode));
 }
コード例 #2
0
 void IClipboardManager.SetText(string text)
 {
     GLFW.SetClipboardString(_glfwWindow, text);
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: liuzhaolovezt/CSGL_Samples
        void MainLoop()
        {
            var waitSemaphores = new List <VkSemaphore> {
                imageAvailableSemaphore
            };
            var waitStages = new List <VkPipelineStageFlags> {
                VkPipelineStageFlags.ColorAttachmentOutputBit
            };
            var signalSemaphores = new List <VkSemaphore> {
                renderFinishedSemaphore
            };
            var swapchains = new List <VkSwapchain> {
                swapchain
            };

            var commandBuffer = new List <VkCommandBuffer> {
                null
            };
            var index = new List <int> {
                0
            };

            var submitInfo = new VkSubmitInfo();

            submitInfo.waitSemaphores   = waitSemaphores;
            submitInfo.waitDstStageMask = waitStages;
            submitInfo.commandBuffers   = commandBuffer;
            submitInfo.signalSemaphores = signalSemaphores;

            var presentInfo = new VkPresentInfo();

            presentInfo.waitSemaphores = signalSemaphores;
            presentInfo.swapchains     = swapchains;
            presentInfo.imageIndices   = index;

            var submitInfos = new List <VkSubmitInfo> {
                submitInfo
            };

            GLFW.ShowWindow(window);

            watch = new Stopwatch();
            watch.Start();

            while (true)
            {
                GLFW.PollEvents();
                if (GLFW.GetKey(window, CSGL.Input.KeyCode.Enter) == CSGL.Input.KeyAction.Press)
                {
                    break;
                }
                if (GLFW.WindowShouldClose(window))
                {
                    break;
                }

                UpdateUniformBuffer();

                if (recreateSwapchainFlag)
                {
                    recreateSwapchainFlag = false;
                    RecreateSwapchain();
                }

                int imageIndex;
                var result = swapchain.AcquireNextImage(-1, imageAvailableSemaphore, null, out imageIndex);

                if (result == VkResult.ErrorOutOfDateKhr || result == VkResult.SuboptimalKhr)
                {
                    RecreateSwapchain();
                    continue;
                }

                commandBuffer[0] = commandBuffers[(int)imageIndex];
                swapchains[0]    = swapchain;
                index[0]         = imageIndex;

                graphicsQueue.Submit(submitInfos, null);
                result = presentQueue.Present(presentInfo);

                if (result == VkResult.ErrorOutOfDateKhr || result == VkResult.SuboptimalKhr)
                {
                    RecreateSwapchain();
                }
            }

            device.WaitIdle();
        }
コード例 #4
0
 private void InitGLContext()
 {
     // Initialize the OpenTK 3 GL context with GLFW.
     _graphicsContext = new GraphicsContext(new ContextHandle((IntPtr)_glfwWindow), GLFW.GetProcAddress,
                                            () => new ContextHandle((IntPtr)GLFW.GetCurrentContext()));
 }
コード例 #5
0
 private void SwapBuffers()
 {
     GLFW.SwapBuffers(_glfwWindow);
 }
コード例 #6
0
 public IntPtr GetProcAddress(string procName)
 {
     return(GLFW.GetProcAddress(procName));
 }
コード例 #7
0
 public bool IsRunning()
 {
     return(GLFW.WindowShouldClose(_window) == 0);
 }
コード例 #8
0
 public void *GLGetProcAddress(string procName)
 {
     return((void *)GLFW.GetProcAddress(procName));
 }
コード例 #9
0
 public override void Update()
 {
     base.Update();
     GLFW.PollEvents();
 }
コード例 #10
0
 private bool Exists()
 {
     return(GLFW.WindowShouldClose(Handle) == 0);
 }
コード例 #11
0
            private Window *CreateGlfwWindowForRenderer(
                GLContextSpec?spec,
                WindowCreateParameters parameters,
                Window *contextShare,
                Window *ownerWindow)
            {
                GLFW.WindowHint(WindowHintString.X11ClassName, "SS14");
                GLFW.WindowHint(WindowHintString.X11InstanceName, "SS14");
                GLFW.WindowHint(WindowHintBool.ScaleToMonitor, true);

                if (spec == null)
                {
                    // No OpenGL context requested.
                    GLFW.WindowHint(WindowHintClientApi.ClientApi, ClientApi.NoApi);
                }
                else
                {
                    var s = spec.Value;

#if DEBUG
                    GLFW.WindowHint(WindowHintBool.OpenGLDebugContext, true);
#endif

                    GLFW.WindowHint(WindowHintInt.ContextVersionMajor, s.Major);
                    GLFW.WindowHint(WindowHintInt.ContextVersionMinor, s.Minor);
                    GLFW.WindowHint(WindowHintBool.OpenGLForwardCompat, s.Profile != GLContextProfile.Compatibility);
                    GLFW.WindowHint(WindowHintBool.SrgbCapable, true);

                    switch (s.Profile)
                    {
                    case GLContextProfile.Compatibility:
                        GLFW.WindowHint(WindowHintOpenGlProfile.OpenGlProfile, OpenGlProfile.Any);
                        GLFW.WindowHint(WindowHintClientApi.ClientApi, ClientApi.OpenGlApi);
                        break;

                    case GLContextProfile.Core:
                        GLFW.WindowHint(WindowHintOpenGlProfile.OpenGlProfile, OpenGlProfile.Core);
                        GLFW.WindowHint(WindowHintClientApi.ClientApi, ClientApi.OpenGlApi);
                        break;

                    case GLContextProfile.Es:
                        GLFW.WindowHint(WindowHintOpenGlProfile.OpenGlProfile, OpenGlProfile.Any);
                        GLFW.WindowHint(WindowHintClientApi.ClientApi, ClientApi.OpenGlEsApi);
                        break;
                    }

                    GLFW.WindowHint(WindowHintContextApi.ContextCreationApi,
                                    s.CreationApi == GLContextCreationApi.Egl
                            ? ContextApi.EglContextApi
                            : ContextApi.NativeContextApi);

#if !FULL_RELEASE
                    if (s.CreationApi == GLContextCreationApi.Egl && !_eglLoaded && OperatingSystem.IsWindows())
                    {
                        // On non-published builds (so, development), GLFW can't find libEGL.dll
                        // because it'll be in runtimes/<rid>/native/ instead of next to the actual executable.
                        // We manually preload the library here so that GLFW will find it when it does its thing.
                        NativeLibrary.TryLoad(
                            "libEGL.dll",
                            typeof(Clyde).Assembly,
                            DllImportSearchPath.SafeDirectories,
                            out _);

                        _eglLoaded = true;
                    }
#endif
                }

                Monitor *monitor = null;
                if (parameters.Monitor != null &&
                    _winThreadMonitors.TryGetValue(parameters.Monitor.Id, out var monitorReg))
                {
                    monitor = monitorReg.Ptr;
                    var mode = GLFW.GetVideoMode(monitor);
                    // Set refresh rate to monitor's so that GLFW doesn't manually select one.
                    GLFW.WindowHint(WindowHintInt.RefreshRate, mode->RefreshRate);
                }
                else
                {
                    GLFW.WindowHint(WindowHintInt.RefreshRate, -1);
                }

                GLFW.WindowHint(WindowHintBool.Visible, false);

                GLFW.WindowHint(WindowHintInt.RedBits, 8);
                GLFW.WindowHint(WindowHintInt.GreenBits, 8);
                GLFW.WindowHint(WindowHintInt.BlueBits, 8);
                GLFW.WindowHint(WindowHintInt.AlphaBits, 8);
                GLFW.WindowHint(WindowHintInt.StencilBits, 8);

                var window = GLFW.CreateWindow(
                    parameters.Width, parameters.Height,
                    parameters.Title,
                    parameters.Fullscreen ? monitor : null,
                    contextShare);

                // Check if window failed to create.
                if (window == null)
                {
                    return(null);
                }

                if (parameters.Maximized)
                {
                    GLFW.GetMonitorPos(monitor, out var x, out var y);
                    GLFW.SetWindowPos(window, x, y);
                    GLFW.MaximizeWindow(window);
                }

                if ((parameters.Styles & OSWindowStyles.NoTitleOptions) != 0)
                {
                    if (OperatingSystem.IsWindows())
                    {
                        var hWnd = (void *)GLFW.GetWin32Window(window);
                        DebugTools.Assert(hWnd != null);

                        Win32.SetWindowLongPtrW(
                            hWnd,
                            Win32.GWL_STYLE,
                            // Cast to long here to work around a bug in rider with nint bitwise operators.
                            (nint)((long)Win32.GetWindowLongPtrW(hWnd, Win32.GWL_STYLE) & ~Win32.WS_SYSMENU));
                    }
                    else
                    {
                        _sawmill.Warning("OSWindowStyles.NoTitleOptions not implemented on this platform");
                    }
                }

                if (ownerWindow != null)
                {
                    if (OperatingSystem.IsWindows())
                    {
                        var hWnd      = (void *)GLFW.GetWin32Window(window);
                        var ownerHWnd = GLFW.GetWin32Window(ownerWindow);
                        DebugTools.Assert(hWnd != null);

                        Win32.SetWindowLongPtrW(
                            hWnd,
                            Win32.GWLP_HWNDPARENT,
                            ownerHWnd);
                    }
                    else
                    {
                        _sawmill.Warning("owner windows not implemented on this platform");
                    }


                    if (parameters.StartupLocation == WindowStartupLocation.CenterOwner)
                    {
                        // TODO: Maybe include window frames in size calculations here?
                        // Figure out frame sizes of both windows.
                        GLFW.GetWindowPos(ownerWindow, out var ownerX, out var ownerY);
                        GLFW.GetWindowSize(ownerWindow, out var ownerW, out var ownerH);

                        // Re-fetch this in case DPI scaling is changing it I guess.
                        GLFW.GetWindowSize(window, out var thisW, out var thisH);

                        GLFW.SetWindowPos(window, ownerX + (ownerW - thisW) / 2, ownerY + (ownerH - thisH) / 2);
                    }
                }

                if (parameters.Visible)
                {
                    GLFW.ShowWindow(window);
                }

                return(window);
            }
コード例 #12
0
ファイル: GLFWGraphicsContext.cs プロジェクト: jvbsl/opentk
 /// <inheritdoc />
 public void MakeNoneCurrent()
 {
     GLFW.MakeContextCurrent(null);
 }
コード例 #13
0
ファイル: GLFWGraphicsContext.cs プロジェクト: jvbsl/opentk
 /// <inheritdoc />
 public void MakeCurrent()
 {
     GLFW.MakeContextCurrent(_windowPtr);
 }
コード例 #14
0
ファイル: GLFWGraphicsContext.cs プロジェクト: jvbsl/opentk
 /// <inheritdoc />
 public void SwapBuffers()
 {
     GLFW.SwapBuffers(_windowPtr);
 }
コード例 #15
0
 private void WinThreadSetClipboard(CmdSetClipboard cmd)
 {
     GLFW.SetClipboardString((Window *)cmd.Window, cmd.Text);
 }
コード例 #16
0
 private void WinThreadWinDestroy(CmdWinDestroy cmd)
 {
     GLFW.DestroyWindow((Window *)cmd.Window);
 }
コード例 #17
0
 public void GLSwapInterval(int interval)
 {
     GLFW.SwapInterval(interval);
 }
コード例 #18
0
 private void WinThreadWinSetTitle(CmdWinSetTitle cmd)
 {
     GLFW.SetWindowTitle((Window *)cmd.Window, cmd.Title);
 }
コード例 #19
0
 public void Cleanup()
 {
     // terminate GLFW, clearing any resources allocated by GLFW
     GLFW.Terminate();
 }
コード例 #20
0
            private void WinThreadWinRequestAttention(CmdWinRequestAttention cmd)
            {
                var win = (Window *)cmd.Window;

                GLFW.RequestWindowAttention(win);
            }
コード例 #21
0
 public void PollEvents()
 {
     GLFW.PollEvents();
 }
コード例 #22
0
            public async Task <WindowHandle> WindowCreate(WindowCreateParameters parameters)
            {
                // tfw await not allowed in unsafe contexts

                // GL APIs don't take kindly to making a new window without unbinding the main context. Great.
                // Leaving code for async path in, in case it works on like GLX.
                var unbindContextAndBlock = true;

                DebugTools.AssertNotNull(_mainWindow);

                Task <GlfwWindowCreateResult> task;

                unsafe
                {
                    if (unbindContextAndBlock)
                    {
                        GLFW.MakeContextCurrent(null);
                    }

                    task = SharedWindowCreate(
                        _clyde._chosenRenderer,
                        parameters,
                        _mainWindow !.GlfwWindow);
                }

                if (unbindContextAndBlock)
                {
                    unsafe
                    {
                        // Block the main thread (to avoid stuff like texture uploads being problematic).
                        WaitWindowCreate(task);

                        if (unbindContextAndBlock)
                        {
                            GLFW.MakeContextCurrent(_mainWindow.GlfwWindow);
                        }
                    }
                }
                else
                {
                    await task;
                }

                var(reg, error) = await task;

                if (reg == null)
                {
                    var(desc, errCode) = error !.Value;
                    throw new GlfwException($"{errCode}: {desc}");
                }

                _clyde.CreateWindowRenderTexture(reg);
                _clyde.InitWindowBlitThread(reg);

                unsafe
                {
                    GLFW.MakeContextCurrent(_mainWindow.GlfwWindow);
                }

                return(reg.Handle);
            }
コード例 #23
0
 public void ProcessInput(FrameEventArgs frameEventArgs)
 {
     GLFW.PollEvents();
 }
コード例 #24
0
            private Window *CreateGlfwWindowForRenderer(
                Renderer r,
                WindowCreateParameters parameters,
                Window *contextShare)
            {
#if DEBUG
                GLFW.WindowHint(WindowHintBool.OpenGLDebugContext, true);
#endif
                GLFW.WindowHint(WindowHintString.X11ClassName, "SS14");
                GLFW.WindowHint(WindowHintString.X11InstanceName, "SS14");

                if (r == Renderer.OpenGL33)
                {
                    GLFW.WindowHint(WindowHintInt.ContextVersionMajor, 3);
                    GLFW.WindowHint(WindowHintInt.ContextVersionMinor, 3);
                    GLFW.WindowHint(WindowHintBool.OpenGLForwardCompat, true);
                    GLFW.WindowHint(WindowHintClientApi.ClientApi, ClientApi.OpenGlApi);
                    GLFW.WindowHint(WindowHintContextApi.ContextCreationApi, ContextApi.NativeContextApi);
                    GLFW.WindowHint(WindowHintOpenGlProfile.OpenGlProfile, OpenGlProfile.Core);
                    GLFW.WindowHint(WindowHintBool.SrgbCapable, true);
                }
                else if (r == Renderer.OpenGL31)
                {
                    GLFW.WindowHint(WindowHintInt.ContextVersionMajor, 3);
                    GLFW.WindowHint(WindowHintInt.ContextVersionMinor, 1);
                    GLFW.WindowHint(WindowHintBool.OpenGLForwardCompat, false);
                    GLFW.WindowHint(WindowHintClientApi.ClientApi, ClientApi.OpenGlApi);
                    GLFW.WindowHint(WindowHintContextApi.ContextCreationApi, ContextApi.NativeContextApi);
                    GLFW.WindowHint(WindowHintOpenGlProfile.OpenGlProfile, OpenGlProfile.Any);
                    GLFW.WindowHint(WindowHintBool.SrgbCapable, true);
                }
                else if (r == Renderer.OpenGLES2)
                {
                    GLFW.WindowHint(WindowHintInt.ContextVersionMajor, 2);
                    GLFW.WindowHint(WindowHintInt.ContextVersionMinor, 0);
                    GLFW.WindowHint(WindowHintBool.OpenGLForwardCompat, true);
                    GLFW.WindowHint(WindowHintClientApi.ClientApi, ClientApi.OpenGlEsApi);
                    // GLES2 is initialized through EGL to allow ANGLE usage.
                    // (It may be an idea to make this a configuration cvar)
                    GLFW.WindowHint(WindowHintContextApi.ContextCreationApi, ContextApi.EglContextApi);
                    GLFW.WindowHint(WindowHintOpenGlProfile.OpenGlProfile, OpenGlProfile.Any);
                    GLFW.WindowHint(WindowHintBool.SrgbCapable, false);
                }


                Monitor *monitor = null;
                if (parameters.Monitor != null &&
                    _winThreadMonitors.TryGetValue(parameters.Monitor.Id, out var monitorReg))
                {
                    monitor = monitorReg.Ptr;
                }

                GLFW.WindowHint(WindowHintBool.Visible, false);

                var window = GLFW.CreateWindow(
                    parameters.Width, parameters.Height,
                    parameters.Title,
                    parameters.Fullscreen ? monitor : null,
                    contextShare);

                // Check if window failed to create.
                if (window == null)
                {
                    return(null);
                }

                if (parameters.Maximized)
                {
                    GLFW.GetMonitorPos(monitor, out var x, out var y);
                    GLFW.SetWindowPos(window, x, y);
                    GLFW.MaximizeWindow(window);
                }

                if (parameters.Visible)
                {
                    GLFW.ShowWindow(window);
                }



                return(window);
            }
コード例 #25
0
 string IClipboardManager.GetText()
 {
     return(GLFW.GetClipboardString(_glfwWindow));
 }
コード例 #26
0
 public int KeyGetScanCode(Keyboard.Key key)
 {
     return(GLFW.GetKeyScancode(ConvertGlfwKeyReverse(key)));
 }
コード例 #27
0
        private void InitWindow()
        {
            GLFW.WindowHint(WindowHintBool.SrgbCapable, true);
            GLFW.WindowHint(WindowHintInt.ContextVersionMajor, MinimumOpenGLVersion.Major);
            GLFW.WindowHint(WindowHintInt.ContextVersionMinor, MinimumOpenGLVersion.Minor);
            GLFW.WindowHint(WindowHintBool.OpenGLForwardCompat, true);
            GLFW.WindowHint(WindowHintOpenGlProfile.OpenGlProfile, OpenGlProfile.Core);
#if DEBUG
            GLFW.WindowHint(WindowHintBool.OpenGLDebugContext, true);
#endif
            GLFW.WindowHint(WindowHintString.X11ClassName, "SS14");
            GLFW.WindowHint(WindowHintString.X11InstanceName, "SS14");

            var width  = _configurationManager.GetCVar <int>("display.width");
            var height = _configurationManager.GetCVar <int>("display.height");

            Monitor *monitor = null;

            if (WindowMode == WindowMode.Fullscreen)
            {
                monitor = GLFW.GetPrimaryMonitor();
                var mode = GLFW.GetVideoMode(monitor);
                width  = mode->Width;
                height = mode->Height;
            }

            _glfwWindow = GLFW.CreateWindow(width, height, string.Empty, monitor, null);

            LoadWindowIcon();

            GLFW.SetCharCallback(_glfwWindow, _charCallback);
            GLFW.SetKeyCallback(_glfwWindow, _keyCallback);
            GLFW.SetWindowCloseCallback(_glfwWindow, _windowCloseCallback);
            GLFW.SetCursorPosCallback(_glfwWindow, _cursorPosCallback);
            GLFW.SetWindowSizeCallback(_glfwWindow, _windowSizeCallback);
            GLFW.SetScrollCallback(_glfwWindow, _scrollCallback);
            GLFW.SetMouseButtonCallback(_glfwWindow, _mouseButtonCallback);
            GLFW.SetWindowContentScaleCallback(_glfwWindow, _windowContentScaleCallback);

            GLFW.MakeContextCurrent(_glfwWindow);

            VSyncChanged();

            GLFW.GetFramebufferSize(_glfwWindow, out var fbW, out var fbH);
            _framebufferSize = (fbW, fbH);

            GLFW.GetWindowContentScale(_glfwWindow, out var scaleX, out var scaleY);
            _windowScale = (scaleX, scaleY);

            GLFW.GetWindowSize(_glfwWindow, out var w, out var h);
            _windowSize = (w, h);

            _pixelRatio = _framebufferSize / _windowSize;

            InitGLContext();

            // Initializing OTK 3 seems to mess with the current context, so ensure it's still set.
            // This took me f*****g *forever* to debug because this manifested differently on nvidia drivers vs intel mesa.
            // So I thought it was a calling convention issue with the calli OpenTK emits.
            // Because, in my tests, I had InitGLContext() AFTER the test with a delegate-based invoke of the proc.
            GLFW.MakeContextCurrent(_glfwWindow);

            InitOpenGL();
        }
コード例 #28
0
 public string KeyGetNameScanCode(int scanCode)
 {
     return(GLFW.GetKeyName(Keys.Unknown, scanCode));
 }
コード例 #29
0
ファイル: Program.cs プロジェクト: liuzhaolovezt/CSGL_Samples
 void CreateWindow()
 {
     GLFW.WindowHint(WindowHint.ClientAPI, (int)ClientAPI.NoAPI);
     GLFW.WindowHint(WindowHint.Visible, 0);
     window = GLFW.CreateWindow(width, height, "Texture Mapping", MonitorPtr.Null, WindowPtr.Null);
 }
コード例 #30
0
        private void InitVeldrid()
        {
            var options = new GraphicsDeviceOptions
            {
#if DEBUG
                Debug = true,
#endif
                HasMainSwapchain    = true,
                SyncToVerticalBlank = _vsync,
                PreferStandardClipSpaceYDirection = true,
                SwapchainSrgbFormat = true
            };

            GLFW.GetFramebufferSize(_window.WindowPtr, out var w, out var h);

            var hwnd      = GLFW.GetWin32Window(_window.WindowPtr);
            var hinstance = GetModuleHandleA(null);

            switch (_vdRenderer)
            {
            case VeldridRenderer.Vulkan:
                _vdGfxDevice = GraphicsDevice.CreateVulkan(
                    options,
                    VkSurfaceSource.CreateWin32((nint)hinstance, hwnd),
                    (uint)w, (uint)h);
                break;

            case VeldridRenderer.D3D11:
                _vdGfxDevice = GraphicsDevice.CreateD3D11(options, hwnd, (uint)w, (uint)h);
                break;

            case VeldridRenderer.OpenGL:
            {
                var platInfo = new OpenGLPlatformInfo(
                    (nint)_window.WindowPtr,
                    GLFW.GetProcAddress,
                    ptr => GLFW.MakeContextCurrent((Window *)ptr),
                    () => (nint)GLFW.GetCurrentContext(),
                    () => GLFW.MakeContextCurrent(null),
                    ptr => GLFW.DestroyWindow((Window *)ptr),
                    () => GLFW.SwapBuffers(_window.WindowPtr),
                    vsync => GLFW.SwapInterval(vsync ? 1 : 0));

                _vdGfxDevice = GraphicsDevice.CreateOpenGL(options, platInfo, (uint)w, (uint)h);
                break;
            }
            }


            var factory = _vdGfxDevice.ResourceFactory;

            _vdCommandList      = factory.CreateCommandList();
            _vdCommandList.Name = "Honk";

            var vtxLayout = new VertexLayoutDescription(
                new VertexElementDescription("Position", VertexElementFormat.Float2,
                                             VertexElementSemantic.TextureCoordinate),
                new VertexElementDescription("UV", VertexElementFormat.Float2, VertexElementSemantic.TextureCoordinate),
                new VertexElementDescription("Color", VertexElementFormat.Byte4_Norm,
                                             VertexElementSemantic.TextureCoordinate));

            var vtxShaderDesc = new ShaderDescription(
                ShaderStages.Vertex,
                Encoding.UTF8.GetBytes(VDVertexShader),
                "main");

            var fragShaderDesc = new ShaderDescription(
                ShaderStages.Fragment,
                Encoding.UTF8.GetBytes(VDFragmentShader),
                "main");

            _vdShaders = factory.CreateFromSpirv(vtxShaderDesc, fragShaderDesc);

            _vdShaders[0].Name = "VertexShader";
            _vdShaders[1].Name = "FragmentShader";

            var layoutTexture = factory.CreateResourceLayout(new ResourceLayoutDescription(
                                                                 new ResourceLayoutElementDescription(
                                                                     "Texture",
                                                                     ResourceKind.TextureReadOnly,
                                                                     ShaderStages.Fragment),
                                                                 new ResourceLayoutElementDescription(
                                                                     "TextureSampler",
                                                                     ResourceKind.Sampler,
                                                                     ShaderStages.Fragment)));

            layoutTexture.Name = "LayoutTexture";

            var layoutProjMatrix = factory.CreateResourceLayout(new ResourceLayoutDescription(
                                                                    new ResourceLayoutElementDescription(
                                                                        "ProjMtx",
                                                                        ResourceKind.UniformBuffer,
                                                                        ShaderStages.Vertex)));

            layoutProjMatrix.Name = "LayoutProjMatrix";

            var pipelineDesc = new GraphicsPipelineDescription(
                new BlendStateDescription(
                    RgbaFloat.White,
                    new BlendAttachmentDescription(
                        true,
                        BlendFactor.SourceAlpha,
                        BlendFactor.InverseSourceAlpha,
                        BlendFunction.Add,
                        BlendFactor.One,
                        BlendFactor.InverseSourceAlpha,
                        BlendFunction.Add)
                    ),
                DepthStencilStateDescription.Disabled,
                new RasterizerStateDescription(
                    FaceCullMode.None,
                    PolygonFillMode.Solid,
                    FrontFace.Clockwise,
                    depthClipEnabled: false,
                    scissorTestEnabled: true),
                PrimitiveTopology.TriangleList,
                new ShaderSetDescription(new[] { vtxLayout }, _vdShaders),
                new[] { layoutProjMatrix, layoutTexture },
                new OutputDescription(
                    null,
                    new OutputAttachmentDescription(PixelFormat.B8_G8_R8_A8_UNorm_SRgb))
                );

            _vdPipeline      = factory.CreateGraphicsPipeline(pipelineDesc);
            _vdPipeline.Name = "MainPipeline";

            _vdProjMatrixUniformBuffer = factory.CreateBuffer(new BufferDescription(
                                                                  (uint)sizeof(Matrix4x4),
                                                                  BufferUsage.Dynamic | BufferUsage.UniformBuffer));
            _vdProjMatrixUniformBuffer.Name = "_vdProjMatrixUniformBuffer";

            _vdSetProjMatrix = factory.CreateResourceSet(new ResourceSetDescription(
                                                             layoutProjMatrix,
                                                             _vdProjMatrixUniformBuffer));
            _vdSetProjMatrix.Name = "_vdSetProjMatrix";
            var io = ImGui.GetIO();

            io.Fonts.GetTexDataAsRGBA32(out byte *pixels, out var width, out var height, out _);

            _vdTexture = factory.CreateTexture(TextureDescription.Texture2D(
                                                   (uint)width, (uint)height,
                                                   mipLevels: 1,
                                                   arrayLayers: 1,
                                                   PixelFormat.R8_G8_B8_A8_UNorm_SRgb,
                                                   TextureUsage.Sampled));

            _vdTexture.Name = "MainTexture";

            _vdSampler = factory.CreateSampler(SamplerDescription.Linear);

            _vdSampler.Name = "MainSampler";

            _vdGfxDevice.UpdateTexture(
                _vdTexture,
                (IntPtr)pixels,
                (uint)(width * height * 4),
                x: 0, y: 0, z: 0,
                (uint)width, (uint)height, depth: 1,
                mipLevel: 0,
                arrayLayer: 0);

            _vdSetTexture = factory.CreateResourceSet(new ResourceSetDescription(
                                                          layoutTexture,
                                                          _vdTexture,
                                                          _vdSampler));

            _vdSetTexture.Name = "SetTexture";

            io.Fonts.SetTexID((nint)0);
            io.Fonts.ClearTexData();

            _vdGfxDevice.ResizeMainWindow((uint)w, (uint)h);
            _vdGfxDevice.SwapBuffers();
        }