public static void TriggerCapture() { RDoc?.TriggerCapture(); }
private void Update(float deltaSeconds) { _fta.AddTime(deltaSeconds); _scene.Update(deltaSeconds); if (ImGui.BeginMainMenuBar()) { if (ImGui.BeginMenu("Settings")) { if (ImGui.BeginMenu("Graphics Backend")) { if (ImGui.MenuItem("Vulkan", string.Empty, _gd.BackendType == GraphicsBackend.Vulkan, GraphicsDevice.IsBackendSupported(GraphicsBackend.Vulkan))) { ChangeBackend(GraphicsBackend.Vulkan); } if (ImGui.MenuItem("OpenGL", string.Empty, _gd.BackendType == GraphicsBackend.OpenGL, GraphicsDevice.IsBackendSupported(GraphicsBackend.OpenGL))) { ChangeBackend(GraphicsBackend.OpenGL); } if (ImGui.MenuItem("OpenGL ES", string.Empty, _gd.BackendType == GraphicsBackend.OpenGLES, GraphicsDevice.IsBackendSupported(GraphicsBackend.OpenGLES))) { ChangeBackend(GraphicsBackend.OpenGLES); } if (ImGui.MenuItem("Direct3D 11", string.Empty, _gd.BackendType == GraphicsBackend.Direct3D11, GraphicsDevice.IsBackendSupported(GraphicsBackend.Direct3D11))) { ChangeBackend(GraphicsBackend.Direct3D11); } if (ImGui.MenuItem("Metal", string.Empty, _gd.BackendType == GraphicsBackend.Metal, GraphicsDevice.IsBackendSupported(GraphicsBackend.Metal))) { ChangeBackend(GraphicsBackend.Metal); } ImGui.EndMenu(); } if (ImGui.BeginMenu("MSAA")) { if (ImGui.Combo("MSAA", ref _msaaOption, _msaaOptions, _msaaOptions.Length)) { ChangeMsaa(_msaaOption); } ImGui.EndMenu(); } bool threadedRendering = _scene.ThreadedRendering; if (ImGui.MenuItem("Render with multiple threads", string.Empty, threadedRendering, true)) { _scene.ThreadedRendering = !_scene.ThreadedRendering; } bool tinted = _fsq.UseTintedTexture; if (ImGui.MenuItem("Tinted output", string.Empty, tinted, true)) { _fsq.UseTintedTexture = !tinted; } ImGui.EndMenu(); } if (ImGui.BeginMenu("Window")) { bool isFullscreen = _window.WindowState == WindowState.BorderlessFullScreen; if (ImGui.MenuItem("Fullscreen", "F11", isFullscreen, true)) { ToggleFullscreenState(); } if (ImGui.MenuItem("Always Recreate Sdl2Window", string.Empty, _recreateWindow, true)) { _recreateWindow = !_recreateWindow; } if (ImGui.IsItemHovered()) { ImGui.SetTooltip( "Causes a new OS window to be created whenever the graphics backend is switched. This is much safer, and is the default."); } if (ImGui.MenuItem("sRGB Swapchain Format", string.Empty, _colorSrgb, true)) { _colorSrgb = !_colorSrgb; ChangeBackend(_gd.BackendType); } bool vsync = _gd.SyncToVerticalBlank; if (ImGui.MenuItem("VSync", string.Empty, vsync, true)) { _gd.SyncToVerticalBlank = !_gd.SyncToVerticalBlank; } bool resizable = _window.Resizable; if (ImGui.MenuItem("Resizable Window", string.Empty, resizable)) { _window.Resizable = !_window.Resizable; } bool bordered = _window.BorderVisible; if (ImGui.MenuItem("Visible Window Border", string.Empty, bordered)) { _window.BorderVisible = !_window.BorderVisible; } ImGui.EndMenu(); } if (ImGui.BeginMenu("Materials")) { if (ImGui.BeginMenu("Brick")) { DrawIndexedMaterialMenu(CommonMaterials.Brick); ImGui.EndMenu(); } if (ImGui.BeginMenu("Vase")) { DrawIndexedMaterialMenu(CommonMaterials.Vase); ImGui.EndMenu(); } if (ImGui.BeginMenu("Reflective")) { DrawIndexedMaterialMenu(CommonMaterials.Reflective); ImGui.EndMenu(); } ImGui.EndMenu(); } if (ImGui.BeginMenu("Debug")) { if (ImGui.MenuItem("Refresh Device Objects")) { RefreshDeviceObjects(1); } if (ImGui.MenuItem("Refresh Device Objects (10 times)")) { RefreshDeviceObjects(10); } if (ImGui.MenuItem("Refresh Device Objects (100 times)")) { RefreshDeviceObjects(100); } if (_controllerTracker != null) { if (ImGui.MenuItem("Controller State")) { _controllerDebugMenu = true; } } else { if (ImGui.MenuItem("Connect to Controller")) { Sdl2ControllerTracker.CreateDefault(out _controllerTracker); _scene.Camera.Controller = _controllerTracker; } } ImGui.EndMenu(); } if (ImGui.BeginMenu("RenderDoc")) { if (_renderDoc == null) { if (ImGui.MenuItem("Load")) { if (RenderDoc.Load(out _renderDoc)) { ChangeBackend(_gd.BackendType); } } } else { if (ImGui.MenuItem("Trigger Capture")) { _renderDoc.TriggerCapture(); } if (ImGui.BeginMenu("Options")) { bool allowVsync = _renderDoc.AllowVSync; if (ImGui.Checkbox("Allow VSync", ref allowVsync)) { _renderDoc.AllowVSync = allowVsync; } bool validation = _renderDoc.APIValidation; if (ImGui.Checkbox("API Validation", ref validation)) { _renderDoc.APIValidation = validation; } int delayForDebugger = (int)_renderDoc.DelayForDebugger; if (ImGui.InputInt("Debugger Delay", ref delayForDebugger)) { delayForDebugger = Math.Clamp(delayForDebugger, 0, int.MaxValue); _renderDoc.DelayForDebugger = (uint)delayForDebugger; } bool verifyBufferAccess = _renderDoc.VerifyBufferAccess; if (ImGui.Checkbox("Verify Buffer Access", ref verifyBufferAccess)) { _renderDoc.VerifyBufferAccess = verifyBufferAccess; } bool overlayEnabled = _renderDoc.OverlayEnabled; if (ImGui.Checkbox("Overlay Visible", ref overlayEnabled)) { _renderDoc.OverlayEnabled = overlayEnabled; } bool overlayFrameRate = _renderDoc.OverlayFrameRate; if (ImGui.Checkbox("Overlay Frame Rate", ref overlayFrameRate)) { _renderDoc.OverlayFrameRate = overlayFrameRate; } bool overlayFrameNumber = _renderDoc.OverlayFrameNumber; if (ImGui.Checkbox("Overlay Frame Number", ref overlayFrameNumber)) { _renderDoc.OverlayFrameNumber = overlayFrameNumber; } bool overlayCaptureList = _renderDoc.OverlayCaptureList; if (ImGui.Checkbox("Overlay Capture List", ref overlayCaptureList)) { _renderDoc.OverlayCaptureList = overlayCaptureList; } ImGui.EndMenu(); } if (ImGui.MenuItem("Launch Replay UI")) { _renderDoc.LaunchReplayUI(); } } ImGui.EndMenu(); } if (_controllerDebugMenu) { if (ImGui.Begin("Controller State", ref _controllerDebugMenu, ImGuiWindowFlags.NoCollapse)) { if (_controllerTracker != null) { ImGui.Columns(2); ImGui.Text($"Name: {_controllerTracker.ControllerName}"); foreach (SDL_GameControllerAxis axis in (SDL_GameControllerAxis[])Enum.GetValues(typeof(SDL_GameControllerAxis))) { ImGui.Text($"{axis}: {_controllerTracker.GetAxis(axis)}"); } ImGui.NextColumn(); foreach (SDL_GameControllerButton button in (SDL_GameControllerButton[])Enum.GetValues(typeof(SDL_GameControllerButton))) { ImGui.Text($"{button}: {_controllerTracker.IsPressed(button)}"); } } else { ImGui.Text("No controller detected."); } } ImGui.End(); } ImGui.Text(_fta.CurrentAverageFramesPerSecond.ToString("000.0 fps / ") + _fta.CurrentAverageFrameTimeMilliseconds.ToString("#00.00 ms")); ImGui.EndMainMenuBar(); } if (InputTracker.GetKeyDown(Key.F11)) { ToggleFullscreenState(); } if (InputTracker.GetKeyDown(Key.Keypad6)) { _window.X += 10; } if (InputTracker.GetKeyDown(Key.Keypad4)) { _window.X -= 10; } if (InputTracker.GetKeyDown(Key.Keypad8)) { _window.Y += 10; } if (InputTracker.GetKeyDown(Key.Keypad2)) { _window.Y -= 10; } _window.Title = _gd.BackendType.ToString(); }
/// <summary> /// Draws a utility window for interacting with RenderDoc /// </summary> public static void ShowRenderDocWindow() { if (RenderDoc.IsLoaded) { ImGui.SetNextWindowSize(new Vector2(264, 487)); } else { ImGui.SetNextWindowSize(new Vector2(264, 80)); } if (ImGui.Begin("RenderDoc")) { if (!RenderDoc.IsLoaded) { if (ImGui.Button("Load RenderDoc")) { RenderDoc.Initialise(); } } else { if (ImGui.Button("Start Replay UI")) { RenderDoc.LaunchReplayUI(); } if (ImGui.Button("Capture Frame")) { RenderDoc.TriggerCapture(); } ImGui.Text("Debug"); ImGui.BeginChild("Debug", new Vector2(0, 82), true); bufferBool = RenderDoc.APIValidation; ImGui.Checkbox("API Validation", ref bufferBool); RenderDoc.APIValidation = bufferBool; bufferBool = RenderDoc.VerifyBufferAccess; ImGui.Checkbox("Verify Buffer Access", ref bufferBool); RenderDoc.VerifyBufferAccess = bufferBool; bufferBool = RenderDoc.DebugOutputMute; ImGui.Checkbox("Debug Output Mute", ref bufferBool); RenderDoc.DebugOutputMute = bufferBool; ImGui.EndChild(); ImGui.Text("Behavior"); ImGui.BeginChild("Behavior", new Vector2(0, 160 + (RenderDoc.CaptureCallstacks ? 26 : 0)), true); bufferBool = RenderDoc.AllowFullscreen; ImGui.Checkbox("Allow Fullscreen", ref bufferBool); RenderDoc.AllowFullscreen = bufferBool; bufferBool = RenderDoc.AllowVSync; ImGui.Checkbox("Allow V-Sync", ref bufferBool); RenderDoc.AllowVSync = bufferBool; bufferBool = RenderDoc.RefAllResources; ImGui.Checkbox("Reference All Resources", ref bufferBool); RenderDoc.RefAllResources = bufferBool; bufferBool = RenderDoc.CaptureAllCmdLists; ImGui.Checkbox("Capture All Command Lists", ref bufferBool); RenderDoc.CaptureAllCmdLists = bufferBool; bufferBool = RenderDoc.CaptureCallstacks; ImGui.Checkbox("Capture Callstacks", ref bufferBool); RenderDoc.CaptureCallstacks = bufferBool; if (RenderDoc.CaptureCallstacks) { bufferBool = RenderDoc.CaptureCallstacksOnlyDraws; ImGui.Checkbox("Capture Callstacks (Only Draws)", ref bufferBool); RenderDoc.CaptureCallstacksOnlyDraws = bufferBool; } bufferBool = RenderDoc.HookIntoChildren; ImGui.Checkbox("Hook Into Child Processes", ref bufferBool); RenderDoc.HookIntoChildren = bufferBool; ImGui.EndChild(); ImGui.Text("Overlay"); ImGui.BeginChild("Overlay", new Vector2(0, 26 + (RenderDoc.OverlayEnabled ? 26 * 3 : 10)), true); bufferBool = RenderDoc.OverlayEnabled; ImGui.Checkbox("Enable Overlay", ref bufferBool); RenderDoc.OverlayEnabled = bufferBool; if (RenderDoc.OverlayEnabled) { bufferBool = RenderDoc.OverlayFrameRate; ImGui.Checkbox("Overlay Framerate", ref bufferBool); RenderDoc.OverlayFrameRate = bufferBool; bufferBool = RenderDoc.OverlayFrameNumber; ImGui.Checkbox("Overlay Frame Number", ref bufferBool); RenderDoc.OverlayFrameNumber = bufferBool; bufferBool = RenderDoc.OverlayCaptureList; ImGui.Checkbox("Overlay Capture List", ref bufferBool); RenderDoc.OverlayCaptureList = bufferBool; } ImGui.EndChild(); } ImGui.End(); } }