diff --git a/src/xenia/ui/gl/gl_immediate_drawer.cc b/src/xenia/ui/gl/gl_immediate_drawer.cc index 42d9293fd..998ff7c50 100644 --- a/src/xenia/ui/gl/gl_immediate_drawer.cc +++ b/src/xenia/ui/gl/gl_immediate_drawer.cc @@ -228,6 +228,14 @@ void GLImmediateDrawer::Draw(const ImmediateDraw& draw) { glDisable(GL_SCISSOR_TEST); } + if (draw.alpha_blend) { + glEnablei(GL_BLEND, 0); + glBlendEquationi(0, GL_FUNC_ADD); + glBlendFunci(0, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } else { + glDisablei(GL_BLEND, 0); + } + if (draw.texture_handle) { glBindTextureUnit(0, static_cast(draw.texture_handle)); } else { @@ -270,16 +278,6 @@ void GLImmediateDrawer::End() { } } -void GLImmediateDrawer::EnableAlphaTest(bool enable) { - if (enable) { - glEnablei(GL_BLEND, 0); - glBlendEquationi(0, GL_FUNC_ADD); - glBlendFunci(0, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } else { - glDisablei(GL_BLEND, 0); - } -} - } // namespace gl } // namespace ui } // namespace xe diff --git a/src/xenia/ui/gl/gl_immediate_drawer.h b/src/xenia/ui/gl/gl_immediate_drawer.h index cf0ed1603..e9e02798e 100644 --- a/src/xenia/ui/gl/gl_immediate_drawer.h +++ b/src/xenia/ui/gl/gl_immediate_drawer.h @@ -37,8 +37,6 @@ class GLImmediateDrawer : public ImmediateDrawer { void EndDrawBatch() override; void End() override; - void EnableAlphaTest(bool enable); - private: void InitializeShaders(); diff --git a/src/xenia/ui/imgui_drawer.cc b/src/xenia/ui/imgui_drawer.cc index 7be42804b..87284ad82 100644 --- a/src/xenia/ui/imgui_drawer.cc +++ b/src/xenia/ui/imgui_drawer.cc @@ -203,16 +203,15 @@ void ImGuiDrawer::RenderDrawLists(ImDrawData* data) { for (int j = 0; j < cmd_list->CmdBuffer.size(); ++j) { const auto& cmd = cmd_list->CmdBuffer[j]; - if (reinterpret_cast(cmd.TextureId) & kIgnoreAlpha) { - drawer->EnableAlphaTest(false); - } - ImmediateDraw draw; draw.primitive_type = ImmediatePrimitiveType::kTriangles; draw.count = cmd.ElemCount; draw.index_offset = index_offset; draw.texture_handle = reinterpret_cast(cmd.TextureId) & 0xFFFFFFFF; + draw.alpha_blend = + reinterpret_cast(cmd.TextureId) & kIgnoreAlpha ? false + : true; draw.scissor = true; draw.scissor_rect[0] = static_cast(cmd.ClipRect.x); draw.scissor_rect[1] = static_cast(height - cmd.ClipRect.w); @@ -220,10 +219,6 @@ void ImGuiDrawer::RenderDrawLists(ImDrawData* data) { draw.scissor_rect[3] = static_cast(cmd.ClipRect.w - cmd.ClipRect.y); drawer->Draw(draw); - if (reinterpret_cast(cmd.TextureId) & kIgnoreAlpha) { - drawer->EnableAlphaTest(true); - } - index_offset += cmd.ElemCount; } diff --git a/src/xenia/ui/immediate_drawer.h b/src/xenia/ui/immediate_drawer.h index 1c064d91b..b5545541e 100644 --- a/src/xenia/ui/immediate_drawer.h +++ b/src/xenia/ui/immediate_drawer.h @@ -87,6 +87,9 @@ struct ImmediateDraw { bool scissor = false; // Scissoring region in framebuffer pixels as (x, y, w, h). int scissor_rect[4] = {0}; + + // Blends this draw with the background depending on its alpha (if true). + bool alpha_blend = true; }; class ImmediateDrawer { @@ -113,8 +116,6 @@ class ImmediateDrawer { // Ends drawing in immediate mode and flushes contents. virtual void End() = 0; - virtual void EnableAlphaTest(bool enable) = 0; - protected: ImmediateDrawer(GraphicsContext* graphics_context) : graphics_context_(graphics_context) {}