From 0c37140690e76d9bcfcc9efe947dc41f94379819 Mon Sep 17 00:00:00 2001 From: zhupengfei Date: Sat, 4 Aug 2018 15:11:51 +0800 Subject: [PATCH] video_core: Allow changing background color while emulation is running As @jroweboy stated, this is just one more atomic in VideoCore. --- src/core/settings.cpp | 2 ++ src/video_core/renderer_opengl/renderer_opengl.cpp | 6 ++++++ src/video_core/video_core.cpp | 1 + src/video_core/video_core.h | 1 + 4 files changed, 10 insertions(+) diff --git a/src/core/settings.cpp b/src/core/settings.cpp index e39f26719..551849b20 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -31,6 +31,8 @@ void Apply() { VideoCore::g_emu_window->UpdateCurrentFramebufferLayout(layout.width, layout.height); } + VideoCore::g_renderer_bg_color_update_requested = true; + if (Core::System::GetInstance().IsPoweredOn()) { Core::DSP().SetSink(values.sink_id, values.audio_device_id); Core::DSP().EnableStretching(values.enable_audio_stretching); diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 96125075f..4dc492299 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -384,6 +384,12 @@ void RendererOpenGL::DrawSingleScreenRotated(const ScreenInfo& screen_info, floa * Draws the emulated screens to the emulator window. */ void RendererOpenGL::DrawScreens() { + if (VideoCore::g_renderer_bg_color_update_requested.exchange(false)) { + // Update background color before drawing + glClearColor(Settings::values.bg_red, Settings::values.bg_green, Settings::values.bg_blue, + 0.0f); + } + auto layout = render_window->GetFramebufferLayout(); const auto& top_screen = layout.top_screen; const auto& bottom_screen = layout.bottom_screen; diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp index 9fc29bbad..d3767a6b4 100644 --- a/src/video_core/video_core.cpp +++ b/src/video_core/video_core.cpp @@ -22,6 +22,7 @@ std::atomic g_shader_jit_enabled; std::atomic g_hw_shader_enabled; std::atomic g_hw_shader_accurate_gs; std::atomic g_hw_shader_accurate_mul; +std::atomic g_renderer_bg_color_update_requested; /// Initialize the video core bool Init(EmuWindow* emu_window) { diff --git a/src/video_core/video_core.h b/src/video_core/video_core.h index 7ede71494..d7a2b26b3 100644 --- a/src/video_core/video_core.h +++ b/src/video_core/video_core.h @@ -25,6 +25,7 @@ extern std::atomic g_shader_jit_enabled; extern std::atomic g_hw_shader_enabled; extern std::atomic g_hw_shader_accurate_gs; extern std::atomic g_hw_shader_accurate_mul; +extern std::atomic g_renderer_bg_color_update_requested; /// Start the video core void Start();