mirror of
https://github.com/ocornut/imgui.git
synced 2026-04-01 21:17:42 -05:00
ImDrawData: added ScaleClipRects() helper (#287)
This commit is contained in:
@@ -833,6 +833,20 @@ void ImDrawData::DeIndexAllBuffers()
|
||||
}
|
||||
}
|
||||
|
||||
// Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
|
||||
void ImDrawData::ScaleClipRects(const ImVec2& scale)
|
||||
{
|
||||
for (int i = 0; i < CmdListsCount; i++)
|
||||
{
|
||||
ImDrawList* cmd_list = CmdLists[i];
|
||||
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
||||
{
|
||||
ImDrawCmd* cmd = &cmd_list->CmdBuffer[cmd_i];
|
||||
cmd->ClipRect = ImVec4(cmd->ClipRect.x * scale.x, cmd->ClipRect.y * scale.y, cmd->ClipRect.z * scale.x, cmd->ClipRect.w * scale.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ImFontAtlias
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user