-
-
Notifications
You must be signed in to change notification settings - Fork 11.4k
Description
Version/Branch of Dear ImGui:
Branch: docking
Back-ends:
imgui_impl_glfw.cpp+ imgui_impl_opengl3.cpp
Compiler, OS:
MSVC 2022 (windows) + GCC/Clang with C++17 standard (linux)
Full config/build information:
OpenGL Version: 4.6 (required minimum)
GLSL Version: #version 460 core
Backend Flags:
ImGuiBackendFlags_RendererHasVtxOffset (automatically set by ImGui_ImplOpenGL3_Init for OpenGL 3.2+)
ImGuiBackendFlags_RendererHasTextures (for dynamic font atlas)
ImPlot Version: v0.17
Details:
Hi,
I’m seeing little red rectangle artifacts on Windows only when rendering dark backgrounds using OpenGL. This is not limited to ImPlot, it appears across all my windows and views, but is most noticeable inside ImPlot plots due to the dark backgrounds.
The issue does not occur:
- on Linux
- on Windows when using light backgrounds
Environment
- OS: Windows 10/11
- Backend: OpenGL 4.6 (imgui_impl_opengl3)
- GPU drivers: latest
- MSAA: disabled
- Linux (same codebase, same GPU): no artifacts at all
Behavior
- Small red rectangular artifacts appear intermittently
- Reproducible only on Windows
- Reproducible only with dark backgrounds
- Happens across multiple windows/views, not just ImPlot
ImPlot plots make the issue more visible due to dark backgrounds and dense geometry
Platform-Specific: The issue is Windows-specific, suggesting a driver or rendering pipeline difference
Theme-Dependent: Only occurs with dark plot backgrounds (ImVec4(0.00f, 0.00f, 0.00f, 0.50f)) but not light backgrounds (ImVec4(0.42f, 0.57f, 1.00f, 0.13f))
Anti-Aliasing Related: Artifacts occurence is reduced when ImDrawListFlags_AntiAliasedLines and ImDrawListFlags_AntiAliasedFill are disabled
Current Workaround
I am currently disabling anti-aliasing on plot draw lists as a workaround:
if (ImPlot::BeginPlot("Plot Title", plotSize, flags))
{
ImDrawList* plotDl = ImPlot::GetPlotDrawList();
if (plotDl)
{
plotDl->Flags &= ~(ImDrawListFlags_AntiAliasedLines | ImDrawListFlags_AntiAliasedFill);
}
// ... render plot content ...
ImPlot::EndPlot();
}
Is this a known Windows-specific rendering issue with anti-aliasing on dark backgrounds?
Are there any backend flags or OpenGL state configurations that could resolve this without disabling AA?
Thank you for taking the time to review this issue. I understand this is a platform-specific rendering problem and I would appreciate any guidance on potential solutions or workarounds.
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
#include <imgui.h>
#include <backends/imgui_impl_glfw.h>
#include <backends/imgui_impl_opengl3.h>
#include <implot.h>
#include <GLFW/glfw3.h>
// ... standard ImGui/GLFW initialization ...
void renderPlot()
{
ImVec2 plotSize = ImVec2(-1, 400);
// Dark theme plot background (triggers artifacts on Windows)
ImPlot::PushStyleColor(ImPlotCol_PlotBg, ImVec4(0.00f, 0.00f, 0.00f, 0.50f));
if (ImPlot::BeginPlot("Test Plot", plotSize))
{
// Artifacts appear here on Windows with dark theme when AA is enabled
// Workaround: Disable AA on plot draw list
// ImDrawList* plotDl = ImPlot::GetPlotDrawList();
// if (plotDl) {
// plotDl->Flags &= ~(ImDrawListFlags_AntiAliasedLines | ImDrawListFlags_AntiAliasedFill);
// }
// Sample data
float xs[100], ys[100];
for (int i = 0; i < 100; i++) {
xs[i] = i * 0.1f;
ys[i] = sin(xs[i]);
}
ImPlot::PlotLine("Sine Wave", xs, ys, 100);
ImPlot::EndPlot();
}
ImPlot::PopStyleColor();
}Initialization Code Reference
My initialization follows standard ImGui/ImPlot setup:
// Setup ImGui context
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
// Initialize ImPlot context (after ImGui context)
ImPlot::CreateContext();
// Setup platform/renderer bindings
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init("#version 460 core");
// Build font atlas after renderer backend initialization
io.Fonts->Build();Rendering Loop
// Begin frame
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
// ... render UI including plots ...
// End frame
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());