Render: Removed the code that disable render if style.Alpha is 0.0f, it is both incorrect (as style Alpha can be modified mid-frame), not really necessary (just tested that full Alpha = 0 will lead to empty draw lists!) and misleading (bulk of the work was already done).

docking
omar 7 years ago
parent 945f4d1ecd
commit cea7492bab

@ -4028,52 +4028,47 @@ void ImGui::Render()
ImGui::EndFrame(); ImGui::EndFrame();
g.FrameCountRendered = g.FrameCount; g.FrameCountRendered = g.FrameCount;
// Skip render altogether if alpha is 0.0 // Gather windows to render
// Note that vertex buffers have been created and are wasted, so it is best practice that you don't create windows in the first place, or consistently respond to Begin() returning false. g.IO.MetricsRenderVertices = g.IO.MetricsRenderIndices = g.IO.MetricsActiveWindows = 0;
if (g.Style.Alpha > 0.0f) g.DrawDataBuilder.Clear();
{ ImGuiWindow* window_to_render_front_most = (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus)) ? g.NavWindowingTarget : NULL;
// Gather windows to render for (int n = 0; n != g.Windows.Size; n++)
g.IO.MetricsRenderVertices = g.IO.MetricsRenderIndices = g.IO.MetricsActiveWindows = 0; {
g.DrawDataBuilder.Clear(); ImGuiWindow* window = g.Windows[n];
ImGuiWindow* window_to_render_front_most = (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus)) ? g.NavWindowingTarget : NULL; if (window->Active && window->HiddenFrames <= 0 && (window->Flags & ImGuiWindowFlags_ChildWindow) == 0 && window != window_to_render_front_most)
for (int n = 0; n != g.Windows.Size; n++) AddWindowToDrawDataSelectLayer(window);
{ }
ImGuiWindow* window = g.Windows[n]; if (window_to_render_front_most && window_to_render_front_most->Active && window_to_render_front_most->HiddenFrames <= 0) // NavWindowingTarget is always temporarily displayed as the front-most window
if (window->Active && window->HiddenFrames <= 0 && (window->Flags & (ImGuiWindowFlags_ChildWindow)) == 0 && window != window_to_render_front_most) AddWindowToDrawDataSelectLayer(window_to_render_front_most);
AddWindowToDrawDataSelectLayer(window); g.DrawDataBuilder.FlattenIntoSingleLayer();
}
if (window_to_render_front_most && window_to_render_front_most->Active && window_to_render_front_most->HiddenFrames <= 0) // NavWindowingTarget is always temporarily displayed as the front-most window // Draw software mouse cursor if requested
AddWindowToDrawDataSelectLayer(window_to_render_front_most); ImVec2 offset, size, uv[4];
g.DrawDataBuilder.FlattenIntoSingleLayer(); if (g.IO.MouseDrawCursor && g.IO.Fonts->GetMouseCursorTexData(g.MouseCursor, &offset, &size, &uv[0], &uv[2]))
{
// Draw software mouse cursor if requested const ImVec2 pos = g.IO.MousePos - offset;
ImVec2 offset, size, uv[4]; const ImTextureID tex_id = g.IO.Fonts->TexID;
if (g.IO.MouseDrawCursor && g.IO.Fonts->GetMouseCursorTexData(g.MouseCursor, &offset, &size, &uv[0], &uv[2])) const float sc = g.Style.MouseCursorScale;
{ g.OverlayDrawList.PushTextureID(tex_id);
const ImVec2 pos = g.IO.MousePos - offset; g.OverlayDrawList.AddImage(tex_id, pos + ImVec2(1,0)*sc, pos+ImVec2(1,0)*sc + size*sc, uv[2], uv[3], IM_COL32(0,0,0,48)); // Shadow
const ImTextureID tex_id = g.IO.Fonts->TexID; g.OverlayDrawList.AddImage(tex_id, pos + ImVec2(2,0)*sc, pos+ImVec2(2,0)*sc + size*sc, uv[2], uv[3], IM_COL32(0,0,0,48)); // Shadow
const float sc = g.Style.MouseCursorScale; g.OverlayDrawList.AddImage(tex_id, pos, pos + size*sc, uv[2], uv[3], IM_COL32(0,0,0,255)); // Black border
g.OverlayDrawList.PushTextureID(tex_id); g.OverlayDrawList.AddImage(tex_id, pos, pos + size*sc, uv[0], uv[1], IM_COL32(255,255,255,255)); // White fill
g.OverlayDrawList.AddImage(tex_id, pos + ImVec2(1,0)*sc, pos+ImVec2(1,0)*sc + size*sc, uv[2], uv[3], IM_COL32(0,0,0,48)); // Shadow g.OverlayDrawList.PopTextureID();
g.OverlayDrawList.AddImage(tex_id, pos + ImVec2(2,0)*sc, pos+ImVec2(2,0)*sc + size*sc, uv[2], uv[3], IM_COL32(0,0,0,48)); // Shadow }
g.OverlayDrawList.AddImage(tex_id, pos, pos + size*sc, uv[2], uv[3], IM_COL32(0,0,0,255)); // Black border if (!g.OverlayDrawList.VtxBuffer.empty())
g.OverlayDrawList.AddImage(tex_id, pos, pos + size*sc, uv[0], uv[1], IM_COL32(255,255,255,255)); // White fill AddDrawListToDrawData(&g.DrawDataBuilder.Layers[0], &g.OverlayDrawList);
g.OverlayDrawList.PopTextureID();
} // Setup ImDrawData structure for end-user
if (!g.OverlayDrawList.VtxBuffer.empty()) SetupDrawData(&g.DrawDataBuilder.Layers[0], &g.DrawData);
AddDrawListToDrawData(&g.DrawDataBuilder.Layers[0], &g.OverlayDrawList); g.IO.MetricsRenderVertices = g.DrawData.TotalVtxCount;
g.IO.MetricsRenderIndices = g.DrawData.TotalIdxCount;
// Setup ImDrawData structure for end-user
SetupDrawData(&g.DrawDataBuilder.Layers[0], &g.DrawData); // Render. If user hasn't set a callback then they may retrieve the draw data via GetDrawData()
g.IO.MetricsRenderVertices = g.DrawData.TotalVtxCount;
g.IO.MetricsRenderIndices = g.DrawData.TotalIdxCount;
// Render. If user hasn't set a callback then they may retrieve the draw data via GetDrawData()
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
if (g.DrawData.CmdListsCount > 0 && g.IO.RenderDrawListsFn != NULL) if (g.DrawData.CmdListsCount > 0 && g.IO.RenderDrawListsFn != NULL)
g.IO.RenderDrawListsFn(&g.DrawData); g.IO.RenderDrawListsFn(&g.DrawData);
#endif #endif
}
} }
const char* ImGui::FindRenderedTextEnd(const char* text, const char* text_end) const char* ImGui::FindRenderedTextEnd(const char* text, const char* text_end)

Loading…
Cancel
Save