From d389fcaa13ca2903c2a88a2b503e725b90ce956a Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 20 Oct 2019 20:51:59 +1000 Subject: [PATCH] Frontend: Force powered-off screen through seperate render path --- src/duckstation/sdl_interface.cpp | 43 +++++++++++++++++++++---------- src/duckstation/sdl_interface.h | 1 + 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/src/duckstation/sdl_interface.cpp b/src/duckstation/sdl_interface.cpp index 47b5254fa..f15f8ba01 100644 --- a/src/duckstation/sdl_interface.cpp +++ b/src/duckstation/sdl_interface.cpp @@ -428,8 +428,7 @@ void SDLInterface::Render() { DrawImGui(); - if (m_system) - m_system->GetGPU()->ResetGraphicsAPIState(); + m_system->GetGPU()->ResetGraphicsAPIState(); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); @@ -447,8 +446,26 @@ void SDLInterface::Render() ImGui::NewFrame(); GL::Program::ResetLastProgram(); - if (m_system) - m_system->GetGPU()->RestoreGraphicsAPIState(); + m_system->GetGPU()->RestoreGraphicsAPIState(); +} + +void SDLInterface::RenderPoweredOff() +{ + DrawPoweredOffWindow(); + ImGui::Render(); + + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + glClear(GL_COLOR_BUFFER_BIT); + + ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); + + SDL_GL_SwapWindow(m_window); + + ImGui_ImplSDL2_NewFrame(m_window); + ImGui_ImplOpenGL3_NewFrame(); + + ImGui::NewFrame(); } static std::tuple CalculateDrawRect(int window_width, int window_height, float display_ratio) @@ -503,10 +520,7 @@ void SDLInterface::DrawImGui() { DrawMainMenuBar(); - if (m_system) - m_system->DrawDebugWindows(); - else - DrawPoweredOffWindow(); + m_system->DrawDebugWindows(); DrawOSDMessages(); @@ -590,7 +604,7 @@ void SDLInterface::DrawMainMenuBar() ImGui::EndMenu(); } - if (m_system && ImGui::BeginMenu("Debug")) + if (ImGui::BeginMenu("Debug")) { m_system->DrawDebugMenus(); ImGui::EndMenu(); @@ -827,13 +841,12 @@ void SDLInterface::Run() } if (m_system) + { m_system->RunFrame(); - Render(); + Render(); - // update fps counter - if (m_system) - { + // update fps counter const double time = m_fps_timer.GetTimeSeconds(); if (time >= 0.25f) { @@ -850,5 +863,9 @@ void SDLInterface::Run() m_fps_timer.Reset(); } } + else + { + RenderPoweredOff(); + } } } diff --git a/src/duckstation/sdl_interface.h b/src/duckstation/sdl_interface.h index 11addee06..6e764fc98 100644 --- a/src/duckstation/sdl_interface.h +++ b/src/duckstation/sdl_interface.h @@ -63,6 +63,7 @@ private: bool HandleSDLEvent(const SDL_Event* event); bool PassEventToImGui(const SDL_Event* event); void Render(); + void RenderPoweredOff(); void RenderDisplay(); void DrawMainMenuBar(); void DrawPoweredOffWindow();