Overview
ImDrawList is the low-level list of polygons that ImGui functions are filling. At the end of each frame, all command lists are passed to your rendering function. You can use ImGui::GetWindowDrawList() to access the current window’s draw list and add custom primitives.
Getting a Draw List
GetWindowDrawList
ImDrawList*
Pointer to the current window’s draw list
Structure
ImVector<ImDrawCmd>
Draw commands. Typically 1 command = 1 GPU draw call (unless it’s a callback).
ImVector<ImDrawIdx>
Index buffer. Each command consumes
ImDrawCmd::ElemCount of these.ImVector<ImDrawVert>
Vertex buffer.
ImDrawListFlags
Flags controlling anti-aliasing and other rendering options.
Clipping
PushClipRect
const ImVec2&
Top-left corner of clipping rectangle
const ImVec2&
Bottom-right corner of clipping rectangle
bool
default:"false"
If true, intersect with current clip rect instead of replacing it
Prefer using higher-level
ImGui::PushClipRect() to affect logic (hit-testing and widget culling).PopClipRect
PushClipRectFullScreen
Texture Management
PushTexture
ImTextureRef
Texture reference to use
PopTexture
Primitive Shapes
AddLine
const ImVec2&
Start point
const ImVec2&
End point
ImU32
Color (use
IM_COL32(r, g, b, a) macro)float
default:"1.0f"
Line thickness in pixels
AddRect
const ImVec2&
Top-left corner
const ImVec2&
Bottom-right corner
ImU32
Color
float
default:"0.0f"
Corner rounding radius
ImDrawFlags
default:"0"
Flags for corner rounding (e.g.,
ImDrawFlags_RoundCornersTopLeft)float
default:"1.0f"
Border thickness
AddRectFilled
AddRectFilledMultiColor
ImU32
Top-left corner color
ImU32
Top-right corner color
ImU32
Bottom-right corner color
ImU32
Bottom-left corner color
AddQuad / AddQuadFilled
AddTriangle / AddTriangleFilled
AddCircle / AddCircleFilled
const ImVec2&
Center point
float
Circle radius
ImU32
Color
int
default:"0"
Number of segments (0 = auto-calculate based on radius)
AddNgon / AddNgonFilled
int
Number of sides (e.g., 5 for pentagon, 6 for hexagon)
AddEllipse / AddEllipseFilled
const ImVec2&
Radius on X and Y axes
float
default:"0.0f"
Rotation in radians
Text
AddText
const ImVec2&
Text position (top-left)
ImU32
Text color
const char*
Start of text string
const char*
End of text string (NULL for null-terminated)
ImFont*
Font to use (extended version)
float
Font size (extended version)
Curves
AddBezierCubic
const ImVec2&
Start point
const ImVec2&
First control point
const ImVec2&
Second control point
const ImVec2&
End point
AddBezierQuadratic
See Also
- Draw Commands - Primitives and path API
- ImDrawCmd - Individual draw command structure
- ImDrawVert - Vertex structure