Example #1
0
        /// <summary>
        /// Frees all graphics resources used by the renderer.
        /// </summary>
        public void Dispose()
        {
#if DEBUG
            using Profiler fullProfiler = new Profiler(GetType());
#endif
            unsafe
            {
                var plIo = ImGui.GetPlatformIO();
                Marshal.FreeHGlobal(plIo.NativePtr->Monitors.Data);
                plIo.NativePtr->Monitors = new ImVector();
            }

            ClearCachedImageResources();

            ImGui.DestroyContext();
            ImPlot.DestroyContext();
            ImNodes.Shutdown();

            pipeline.Dispose();
            vertexBuffer.Dispose();
            indexBuffer.Dispose();
            projMatrixBuffer.Dispose();
            fontTextureResourceSet.Dispose();
            fontTextureView.Dispose();
            fontTexture.Dispose();
            vertexShader.Dispose();
            fragmentShader.Dispose();
            mainResourceSet.Dispose();
            layout.Dispose();
            textureLayout.Dispose();
        }
Example #2
0
        /// <summary>
        /// Constructs a new ImGuiController.
        /// </summary>
        public ImGuiController(GraphicsDevice gd, OutputDescription outputDescription, WindowBase window)
        {
#if DEBUG
            using Profiler fullProfiler = new Profiler(GetType());
#endif
            mainWindow = window;
            Sdl2Window sdlWindow = window.SdlWindow;

            windowWidth  = sdlWindow.Width;
            windowHeight = sdlWindow.Height;

            ImPlot.CreateContext();

            ImNodes.Initialize();

            IntPtr imguiCtx = ImGui.CreateContext();
            ImGui.SetCurrentContext(imguiCtx);
            ImPlot.SetImGuiContext(imguiCtx);
            ImNodes.SetImGuiContext(imguiCtx);
            ImGuizmo.SetImGuiContext(imguiCtx);

            ImGui.StyleColorsDark();

            CreateDeviceResources(gd, outputDescription);

            SetupImGuiIo(sdlWindow);
            SetImGuiKeyMappings();

            SetPerFrameImGuiData(1f / 60);
        }