Frontend: Force powered-off screen through seperate render path

This commit is contained in:
Connor McLaughlin 2019-10-20 20:51:59 +10:00
parent 0b58f1facf
commit d389fcaa13
2 changed files with 31 additions and 13 deletions

View file

@ -428,8 +428,7 @@ void SDLInterface::Render()
{ {
DrawImGui(); DrawImGui();
if (m_system) m_system->GetGPU()->ResetGraphicsAPIState();
m_system->GetGPU()->ResetGraphicsAPIState();
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
@ -447,8 +446,26 @@ void SDLInterface::Render()
ImGui::NewFrame(); ImGui::NewFrame();
GL::Program::ResetLastProgram(); 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<int, int, int, int> CalculateDrawRect(int window_width, int window_height, float display_ratio) static std::tuple<int, int, int, int> CalculateDrawRect(int window_width, int window_height, float display_ratio)
@ -503,10 +520,7 @@ void SDLInterface::DrawImGui()
{ {
DrawMainMenuBar(); DrawMainMenuBar();
if (m_system) m_system->DrawDebugWindows();
m_system->DrawDebugWindows();
else
DrawPoweredOffWindow();
DrawOSDMessages(); DrawOSDMessages();
@ -590,7 +604,7 @@ void SDLInterface::DrawMainMenuBar()
ImGui::EndMenu(); ImGui::EndMenu();
} }
if (m_system && ImGui::BeginMenu("Debug")) if (ImGui::BeginMenu("Debug"))
{ {
m_system->DrawDebugMenus(); m_system->DrawDebugMenus();
ImGui::EndMenu(); ImGui::EndMenu();
@ -827,13 +841,12 @@ void SDLInterface::Run()
} }
if (m_system) if (m_system)
{
m_system->RunFrame(); m_system->RunFrame();
Render(); Render();
// update fps counter // update fps counter
if (m_system)
{
const double time = m_fps_timer.GetTimeSeconds(); const double time = m_fps_timer.GetTimeSeconds();
if (time >= 0.25f) if (time >= 0.25f)
{ {
@ -850,5 +863,9 @@ void SDLInterface::Run()
m_fps_timer.Reset(); m_fps_timer.Reset();
} }
} }
else
{
RenderPoweredOff();
}
} }
} }

View file

@ -63,6 +63,7 @@ private:
bool HandleSDLEvent(const SDL_Event* event); bool HandleSDLEvent(const SDL_Event* event);
bool PassEventToImGui(const SDL_Event* event); bool PassEventToImGui(const SDL_Event* event);
void Render(); void Render();
void RenderPoweredOff();
void RenderDisplay(); void RenderDisplay();
void DrawMainMenuBar(); void DrawMainMenuBar();
void DrawPoweredOffWindow(); void DrawPoweredOffWindow();