コード例 #1
0
        static void Main(string[] args)
        {
            // Create window, GraphicsDevice, and all resources necessary for the demo.
            VeldridStartup.CreateWindowAndGraphicsDevice(
                new WindowCreateInfo(50, 50, 1280, 720, WindowState.Normal, "GraphicsVisualizer"),
                new GraphicsDeviceOptions(true, null, true),
                out _window,
                out _gd);
            _window.Resized += () =>
            {
                _gd.MainSwapchain.Resize((uint)_window.Width, (uint)_window.Height);
                _controller.WindowResized(_window.Width, _window.Height);
            };
            _cl           = _gd.ResourceFactory.CreateCommandList();
            _controller   = new ImGuiController(_gd, _gd.MainSwapchain.Framebuffer.OutputDescription, _window.Width, _window.Height);
            _memoryEditor = new MemoryEditor();
            Random random = new Random();

            _memoryEditorData = Enumerable.Range(0, 1024).Select(i => (byte)random.Next(255)).ToArray();
            _transformExample = new TransformExample(_gd);
            _transformUIData  = new TransformUIData();

            // Main application loop
            while (_window.Exists)
            {
                InputSnapshot snapshot = _window.PumpEvents();
                if (!_window.Exists)
                {
                    break;
                }
                _controller.Update(1f / 60f, snapshot); // Feed the input events to our ImGui controller, which passes them through to ImGui.
                _transformExample.Update(_transformUIData);

                SubmitBaseUI();
                SubmitOtherUI();

                _cl.Begin();
                _cl.SetFramebuffer(_gd.MainSwapchain.Framebuffer);
                _cl.ClearColorTarget(0, new RgbaFloat(_clearColor.X, _clearColor.Y, _clearColor.Z, 1f));
                _transformExample.Draw(_cl);
                _controller.Render(_gd, _cl);
                _cl.End();
                _gd.SubmitCommands(_cl);


                _gd.SwapBuffers(_gd.MainSwapchain);
            }

            // Clean up Veldrid resources
            _gd.WaitForIdle();
            _controller.Dispose();
            _cl.Dispose();
            _gd.Dispose();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: zerhacken/hacksager
        static void Main(string[] args)
        {
            VeldridStartup.CreateWindowAndGraphicsDevice(
                new WindowCreateInfo(50, 50, 1280, 720, WindowState.Normal, "ImGui.NET"),
                new GraphicsDeviceOptions(true, null, true),
                out m_window,
                out m_device);

            m_window.Resized += () =>
            {
                m_device.MainSwapchain.Resize((uint)m_window.Width, (uint)m_window.Height);
                m_controller.WindowResized(m_window.Width, m_window.Height);
            };

            m_commandList = m_device.ResourceFactory.CreateCommandList();
            m_controller  = new ImGuiController(m_device, m_device.MainSwapchain.Framebuffer.OutputDescription, m_window.Width, m_window.Height);

            // Main application loop
            while (m_window.Exists)
            {
                InputSnapshot snapshot = m_window.PumpEvents();
                if (!m_window.Exists)
                {
                    break;
                }
                m_controller.Update(1f / 60f, snapshot); // Feed the input events to our ImGui controller, which passes them through to ImGui.

                SubmitUI();

                m_commandList.Begin();
                m_commandList.SetFramebuffer(m_device.MainSwapchain.Framebuffer);
                m_commandList.ClearColorTarget(0, new RgbaFloat(m_clearColor.X, m_clearColor.Y, m_clearColor.Z, 1f));
                m_controller.Render(m_device, m_commandList);
                m_commandList.End();
                m_device.SubmitCommands(m_commandList);
                m_device.SwapBuffers(m_device.MainSwapchain);
            }

            // Clean up Veldrid resources
            m_device.WaitForIdle();
            m_controller.Dispose();
            m_commandList.Dispose();
            m_device.Dispose();
        }