Skip to main content
Windows are the primary containers in Dear ImGui. They can contain any widgets, can be moved, resized, collapsed, and docked (in the docking branch).

Begin

Starts a new window and pushes it onto the window stack.

Parameters

const char*
required
Window title and unique identifier. Use ”###” to separate display name from ID (e.g., “MyWindow###UniqueID”).
bool*
default:"NULL"
Pointer to a boolean controlling window visibility. When not NULL, displays a close button that sets this to false when clicked.
ImGuiWindowFlags
default:"0"
Window behavior flags. See ImGuiWindowFlags_ enum for available options.

Returns

bool
Returns false if the window is collapsed or fully clipped. You can use this to skip rendering content, but you must still call End().

Description

Begin() pushes a window onto the stack and begins appending to it. Key points:
  • Always call End() for each Begin(), regardless of return value
  • Return value indicates visibility, not whether you should call End()
  • Multiple Begin()/End() pairs with the same name append to the same window
  • First call in a frame determines window flags and p_open behavior

Example

Common Flags

Important: Due to legacy reasons, Begin/End are inconsistent with other BeginXXX/EndXXX functions. You must always call End() even if Begin() returns false. This will be fixed in a future update.

End

Pops the current window from the stack.

Description

Ends the current window context. Must be called for every Begin() call, regardless of its return value.

Example

The bottom of the window stack always contains a window called “Debug”. You cannot pop this window.

Window Positioning and Sizing

SetNextWindowPos

Sets the position of the next window before Begin().

Parameters

const ImVec2&
required
Window position in screen coordinates.
ImGuiCond
default:"0"
Condition for setting position. Use ImGuiCond_FirstUseEver to allow user to move window.
const ImVec2&
default:"ImVec2(0, 0)"
Pivot point for positioning. (0,0) = top-left, (0.5,0.5) = center, (1,1) = bottom-right.

Example

SetNextWindowSize

Sets the size of the next window before Begin().

Parameters

const ImVec2&
required
Window size. Set axis to 0.0f to force auto-fit on that axis.
ImGuiCond
default:"0"
Condition for setting size.

Example

Complete Window Example