Add a flag to ImTextureID that disables alpha test
This commit is contained in:
parent
65d1ea0250
commit
a8dfd6a21a
|
@ -270,6 +270,16 @@ 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 gl
|
||||||
} // namespace ui
|
} // namespace ui
|
||||||
} // namespace xe
|
} // namespace xe
|
||||||
|
|
|
@ -37,6 +37,8 @@ class GLImmediateDrawer : public ImmediateDrawer {
|
||||||
void EndDrawBatch() override;
|
void EndDrawBatch() override;
|
||||||
void End() override;
|
void End() override;
|
||||||
|
|
||||||
|
void EnableAlphaTest(bool enable);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InitializeShaders();
|
void InitializeShaders();
|
||||||
|
|
||||||
|
|
|
@ -203,11 +203,16 @@ void ImGuiDrawer::RenderDrawLists(ImDrawData* data) {
|
||||||
for (int j = 0; j < cmd_list->CmdBuffer.size(); ++j) {
|
for (int j = 0; j < cmd_list->CmdBuffer.size(); ++j) {
|
||||||
const auto& cmd = cmd_list->CmdBuffer[j];
|
const auto& cmd = cmd_list->CmdBuffer[j];
|
||||||
|
|
||||||
|
if (reinterpret_cast<uintptr_t>(cmd.TextureId) & kIgnoreAlpha) {
|
||||||
|
drawer->EnableAlphaTest(false);
|
||||||
|
}
|
||||||
|
|
||||||
ImmediateDraw draw;
|
ImmediateDraw draw;
|
||||||
draw.primitive_type = ImmediatePrimitiveType::kTriangles;
|
draw.primitive_type = ImmediatePrimitiveType::kTriangles;
|
||||||
draw.count = cmd.ElemCount;
|
draw.count = cmd.ElemCount;
|
||||||
draw.index_offset = index_offset;
|
draw.index_offset = index_offset;
|
||||||
draw.texture_handle = reinterpret_cast<uintptr_t>(cmd.TextureId);
|
draw.texture_handle =
|
||||||
|
reinterpret_cast<uintptr_t>(cmd.TextureId) & 0xFFFFFFFF;
|
||||||
draw.scissor = true;
|
draw.scissor = true;
|
||||||
draw.scissor_rect[0] = static_cast<int>(cmd.ClipRect.x);
|
draw.scissor_rect[0] = static_cast<int>(cmd.ClipRect.x);
|
||||||
draw.scissor_rect[1] = static_cast<int>(height - cmd.ClipRect.w);
|
draw.scissor_rect[1] = static_cast<int>(height - cmd.ClipRect.w);
|
||||||
|
@ -215,6 +220,10 @@ void ImGuiDrawer::RenderDrawLists(ImDrawData* data) {
|
||||||
draw.scissor_rect[3] = static_cast<int>(cmd.ClipRect.w - cmd.ClipRect.y);
|
draw.scissor_rect[3] = static_cast<int>(cmd.ClipRect.w - cmd.ClipRect.y);
|
||||||
drawer->Draw(draw);
|
drawer->Draw(draw);
|
||||||
|
|
||||||
|
if (reinterpret_cast<uintptr_t>(cmd.TextureId) & kIgnoreAlpha) {
|
||||||
|
drawer->EnableAlphaTest(true);
|
||||||
|
}
|
||||||
|
|
||||||
index_offset += cmd.ElemCount;
|
index_offset += cmd.ElemCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,8 @@ class ImGuiDrawer : public WindowListener {
|
||||||
|
|
||||||
ImGuiIO& GetIO();
|
ImGuiIO& GetIO();
|
||||||
|
|
||||||
|
static const uint64_t kIgnoreAlpha = (1ull << 32);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Initialize();
|
void Initialize();
|
||||||
void SetupFont();
|
void SetupFont();
|
||||||
|
|
|
@ -113,6 +113,8 @@ class ImmediateDrawer {
|
||||||
// Ends drawing in immediate mode and flushes contents.
|
// Ends drawing in immediate mode and flushes contents.
|
||||||
virtual void End() = 0;
|
virtual void End() = 0;
|
||||||
|
|
||||||
|
virtual void EnableAlphaTest(bool enable) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ImmediateDrawer(GraphicsContext* graphics_context)
|
ImmediateDrawer(GraphicsContext* graphics_context)
|
||||||
: graphics_context_(graphics_context) {}
|
: graphics_context_(graphics_context) {}
|
||||||
|
|
Loading…
Reference in New Issue