ImGui
BeamNG ImGui API Reference
All functions via `local im = ui_imgui`. Types: `BoolPtr`, `IntPtr`, `FloatPtr` are `{[0]=value}` tables. `ArrayChar` is a string buffer. `ImVec2(x,y)` and `ImVec4(x,y,z,w)` are engine structs.
All functions via local im = ui_imgui. Types: BoolPtr, IntPtr, FloatPtr are {[0]=value} tables. ArrayChar is a string buffer. ImVec2(x,y) and ImVec4(x,y,z,w) are engine structs.
Data Type Constructors
| Function | Returns | Description |
|---|---|---|
im.BoolPtr(bool) | {[0]=bool} | |
im.IntPtr(int) | {[0]=int} | |
im.FloatPtr(float) | {[0]=float} | |
im.DoublePtr(double) | {[0]=double} | |
im.ArrayChar(size, default) | string | buffer (use ffi.string() to read) |
im.ArrayFloat(size) | {[0]=0, [1]=0, ...} | |
im.ArrayInt(size) | {[0]=0, [1]=0, ...} | |
im.ImVec2(x, y) | ImVec2 | |
im.ImVec4(x, y, z, w) | ImVec4 | |
im.ImColor(r, g, b, a) | ImColor | 0-255 range |
im.ImColorByRGB(r, g, b, a) | ImColor | with .Value as ImVec4 |
im.Int(x) | int | for RadioButton2 etc. |
Windows
| Function | Returns | Description |
|---|---|---|
im.Begin(name, [boolPtr], [flags]) | bool | window visible |
im.End() | - | |
im.BeginChild1(strId, [size], [border], [flags]) | bool | |
im.BeginChild2(intId, [size], [border], [flags]) | bool | |
im.EndChild() | - | |
im.BeginChildFrame(id, size, [flags]) | bool | |
im.EndChildFrame() | - |
Window properties
| Function | Returns | Description |
|---|---|---|
im.IsWindowAppearing() | bool | |
im.IsWindowCollapsed() | bool | |
im.IsWindowFocused([flags]) | bool | |
im.IsWindowHovered([flags]) | bool | |
im.IsWindowDocked() | bool | |
im.GetWindowDrawList() | ImDrawList | |
im.GetWindowDpiScale() | float | |
im.GetWindowPos() | ImVec2 | |
im.GetWindowSize() | ImVec2 | |
im.GetWindowWidth() | float | |
im.GetWindowHeight() | float | |
im.GetWindowViewport() | ImGuiViewport | |
im.GetWindowDockID() | int | |
im.GetWindowContentRegionMin() | ImVec2 | |
im.GetWindowContentRegionMax() | ImVec2 | |
im.GetContentRegionAvail() | ImVec2 |
Window manipulation
| Function | Returns | Description |
|---|---|---|
im.SetNextWindowPos(pos, [cond], [pivot]) | - | |
im.SetNextWindowSize(size, [cond]) | - | |
im.SetNextWindowSizeConstraints(minSize, maxSize) | - | |
im.SetNextWindowContentSize(size) | - | |
im.SetNextWindowCollapsed(collapsed, [cond]) | - | |
im.SetNextWindowFocus() | - | |
im.SetNextWindowScroll(scroll) | - | |
im.SetNextWindowBgAlpha(alpha) | - | |
im.SetNextWindowDockID(dockId, [cond]) | - | |
im.SetNextWindowViewport(viewportId) | - | |
im.SetWindowFontScale(scale) | - |
Text
| Function | Returns | Description |
|---|---|---|
im.Text(fmt, ...) | - | |
im.TextColored(color, fmt, ...) | - | color is ImVec4 |
im.TextDisabled(fmt, ...) | - | |
im.TextWrapped(fmt, ...) | - | |
im.TextUnformatted(text) | - | |
im.LabelText(label, fmt, ...) | - | |
im.BulletText(fmt, ...) | - | |
im.SeparatorText(label) | - |
Buttons
| Function | Returns | Description |
|---|---|---|
im.Button(label, [size]) | bool | |
im.SmallButton(label) | bool | |
im.InvisibleButton(strId, size, [flags]) | bool | |
im.ArrowButton(strId, dir) | bool | |
im.ImageButton(strId, texId, size, [uv0], [uv1], [bgCol], [tintCol]) | bool | |
im.Checkbox(label, boolPtr) | bool | changed |
im.CheckboxFlags1(label, intPtr, flagValue) | bool | |
im.RadioButton1(label, active) | bool | |
im.RadioButton2(label, intPtr, value) | bool |
Inputs - Numeric
| Function | Returns | Description |
|---|---|---|
im.InputInt(label, intPtr, [step], [fastStep], [flags]) | bool | |
im.InputInt2(label, intArray, [flags]) | bool | |
im.InputInt3(label, intArray, [flags]) | bool | |
im.InputInt4(label, intArray, [flags]) | bool | |
im.InputFloat(label, floatPtr, [step], [fastStep], [fmt], [flags]) | bool | |
im.InputFloat2(label, floatArray, [fmt], [flags]) | bool | |
im.InputFloat3(label, floatArray, [fmt], [flags]) | bool | |
im.InputFloat4(label, floatArray, [fmt], [flags]) | bool | |
im.InputDouble(label, doublePtr, [step], [fastStep], [fmt], [flags]) | bool |
Inputs - Text
| Function | Returns | Description |
|---|---|---|
im.InputText(label, buf, [bufSize], [flags], [callback], [userData]) | bool | |
im.InputTextMultiline(label, buf, [bufSize], [size], [flags]) | bool | |
im.InputTextWithHint(label, hint, buf, bufSize, [flags]) | bool |
Sliders
| Function | Returns | Description |
|---|---|---|
im.SliderInt(label, intPtr, min, max, [fmt], [flags]) | bool | |
im.SliderInt2(label, intArray, min, max, [fmt], [flags]) | - | |
im.SliderInt3(label, intArray, min, max, [fmt], [flags]) | - | |
im.SliderInt4(label, intArray, min, max, [fmt], [flags]) | - | |
im.SliderFloat(label, floatPtr, min, max, [fmt], [flags]) | bool | |
im.SliderFloat2(label, floatArray, min, max, [fmt], [flags]) | - | |
im.SliderFloat3(label, floatArray, min, max, [fmt], [flags]) | - | |
im.SliderFloat4(label, floatArray, min, max, [fmt], [flags]) | - | |
im.SliderAngle(label, floatPtr, [minDeg], [maxDeg], [fmt], [flags]) | - | |
im.VSliderInt(label, size, intPtr, min, max, [fmt], [flags]) | - | |
im.VSliderFloat(label, size, floatPtr, min, max, [fmt], [flags]) | - |
Drags
| Function | Returns | Description |
|---|---|---|
im.DragInt(label, intPtr, [speed], [min], [max], [fmt], [flags]) | - | |
im.DragInt2(label, intArray, [speed], [min], [max], [fmt], [flags]) | - | |
im.DragInt3 / DragInt4 | - | same pattern |
im.DragIntRange2(label, intPtrMin, intPtrMax, [speed], [min], [max], [fmt], [fmtMax], [flags]) | - | |
im.DragFloat(label, floatPtr, [speed], [min], [max], [fmt], [flags]) | - | |
im.DragFloat2 / DragFloat3 / DragFloat4 | - | same pattern |
im.DragFloatRange2(label, floatPtrMin, floatPtrMax, ...) | - |
Combo / Selectable
| Function | Returns | Description |
|---|---|---|
im.BeginCombo(label, previewValue, [flags]) | bool | |
im.EndCombo() | - | |
im.Selectable1(label, selected, [flags], [size]) | bool | |
im.Selectable2(label, boolPtr, [flags], [size]) | bool | |
im.BeginListBox(label, [size]) | bool | |
im.EndListBox() | - |
Color
| Function | Returns | Description |
|---|---|---|
im.ColorEdit3(label, floatArray3, [flags]) | bool | |
im.ColorEdit4(label, floatArray4, [flags]) | bool | |
im.ColorPicker3(label, floatArray3, [flags]) | bool | |
im.ColorPicker4(label, floatArray4, [flags]) | bool | |
im.ColorButton(desc, color, [flags], [size]) | bool |
Layout & Spacing
| Function | Returns | Description |
|---|---|---|
im.Separator() | - | |
im.SameLine([offsetX], [spacing]) | - | |
im.NewLine() | - | |
im.Spacing() | - | |
im.Dummy(size) | - | |
im.Indent([width]) | - | |
im.Unindent([width]) | - | |
im.BeginGroup() | - | |
im.EndGroup() | - | |
im.Bullet() | - |
Cursor
| Function | Returns | Description |
|---|---|---|
im.GetCursorPos() | ImVec2 | |
im.GetCursorPosX() | float | |
im.GetCursorPosY() | float | |
im.SetCursorPos(localPos) | - | |
im.SetCursorPosX(x) | - | |
im.SetCursorPosY(y) | - | |
im.GetCursorStartPos() | ImVec2 | |
im.GetCursorScreenPos() | ImVec2 | |
im.SetCursorScreenPos(pos) | - |
Sizing
| Function | Returns | Description |
|---|---|---|
im.SetNextItemWidth(width) | - | |
im.PushItemWidth(width) | - | |
im.PopItemWidth() | - | |
im.CalcItemWidth() | float | |
im.CalcTextSize(text) | ImVec2 | |
im.GetTextLineHeight() | float | |
im.GetFrameHeight() | float | |
im.AlignTextToFramePadding() | - |
Scrolling
| Function | Returns | Description |
|---|---|---|
im.GetScrollX() / GetScrollY() | float | |
im.SetScrollX(x) / SetScrollY(y) | - | |
im.GetScrollMaxX() / GetScrollMaxY() | - | |
im.SetScrollHereX([ratio]) / SetScrollHereY([ratio]) | - |
Tree / Collapsible
| Function | Returns | Description |
|---|---|---|
im.TreeNode1(label) | bool | call TreePop if true |
im.TreeNode2(strId, fmt, ...) | bool | |
im.TreeNodeEx1(label, [flags]) | bool | |
im.TreePop() | - | |
im.CollapsingHeader1(label, [flags]) | bool | |
im.CollapsingHeader2(label, boolPtr, [flags]) | bool | |
im.SetNextItemOpen(open, [cond]) | - | |
im.GetTreeNodeToLabelSpacing() | float |
Tables
| Function | Returns | Description |
|---|---|---|
im.BeginTable(strId, numColumns, [flags], [outerSize], [innerWidth]) | bool | |
im.EndTable() | - | |
im.TableNextRow([flags], [minRowHeight]) | - | |
im.TableNextColumn() | bool | |
im.TableSetColumnIndex(n) | bool | |
im.TableSetupColumn(label, [flags], [initWidth], [userId]) | - | |
im.TableSetupScrollFreeze(cols, rows) | - | |
im.TableHeadersRow() | - | |
im.TableHeader(label) | - | |
im.TableGetSortSpecs() | ImGuiTableSortSpecs | |
im.TableGetColumnCount() | int | |
im.TableGetColumnIndex() | int | |
im.TableGetRowIndex() | int | |
im.TableGetColumnName([n]) | string | |
im.TableGetColumnFlags([n]) | - | |
im.TableSetColumnEnabled(n, enabled) | - | |
im.TableSetBgColor(target, color, [colN]) | - |
Tabs
| Function | Returns | Description |
|---|---|---|
im.BeginTabBar(strId, [flags]) | bool | |
im.EndTabBar() | - | |
im.BeginTabItem(label, [boolPtr], [flags]) | bool | |
im.EndTabItem() | - | |
im.TabItemButton(label, [flags]) | bool | |
im.SetTabItemClosed(tabLabel) | - |
Popups & Modals
| Function | Returns | Description |
|---|---|---|
im.OpenPopup("id", [flags]) | - | |
im.BeginPopup(strId, [flags]) | bool | |
im.BeginPopupModal(name, [boolPtr], [flags]) | bool | |
im.EndPopup() | - | |
im.CloseCurrentPopup() | - | |
im.IsPopupOpen(strId, [flags]) | bool | |
im.BeginPopupContextItem([strId], [flags]) | bool | |
im.BeginPopupContextWindow([strId], [flags]) | bool | |
im.BeginPopupContextVoid([strId], [flags]) | bool | |
im.OpenPopupOnItemClick([strId], [flags]) | - |
Menus
| Function | Returns | Description |
|---|---|---|
im.BeginMenuBar() | bool | |
im.EndMenuBar() | - | |
im.BeginMainMenuBar() | bool | |
im.EndMainMenuBar() | - | |
im.BeginMenu(label, [enabled]) | bool | |
im.EndMenu() | - | |
im.MenuItem1(label, [shortcut], [selected], [enabled]) | bool | |
im.MenuItem2(label, shortcut, boolPtr, [enabled]) | bool |
Tooltip
| Function | Returns | Description |
|---|---|---|
im.BeginTooltip() | - | |
im.EndTooltip() | - | |
im.BeginItemTooltip() | bool | |
im.SetTooltip(fmt, ...) | - | |
im.SetItemTooltip(fmt, ...) | - |
ID Management
| Function | Returns | Description |
|---|---|---|
im.PushID1(strId) | - | |
im.PushID4(intId) | - | |
im.PopID() | - | |
im.GetID1(strId) | ImGuiID |
Style
| Function | Returns | Description |
|---|---|---|
im.PushStyleColor1(colIdx, u32Color) | - | |
im.PushStyleColor2(colIdx, vec4Color) | - | |
im.PopStyleColor([count]) | - | |
im.PushStyleVar1(varIdx, floatVal) | - | |
im.PushStyleVar2(varIdx, vec2Val) | - | |
im.PopStyleVar([count]) | - | |
im.GetStyle() | ImGuiStyle | |
im.GetStyleColorVec4(idx) | ImVec4 | |
im.GetStyleColorName(idx) | string |
Font
| Function | Returns | Description |
|---|---|---|
im.PushFont(font) | - | |
im.PopFont() | - | |
im.PushFont2(index) | - | by font index |
im.PushFont3(uniqueId) | - | by unique id (e.g. "cairo_regular_medium") |
im.GetFont() | - | |
im.GetFontSize() | float |
Item State
| Function | Returns | Description |
|---|---|---|
im.IsItemHovered([flags]) | bool | |
im.IsItemActive() | bool | |
im.IsItemFocused() | bool | |
im.IsItemClicked([button]) | bool | |
im.IsItemVisible() | bool | |
im.IsItemEdited() | bool | |
im.IsItemActivated() | bool | |
im.IsItemDeactivated() | bool | |
im.IsItemDeactivatedAfterEdit() | bool | |
im.IsItemToggledOpen() | bool | |
im.IsAnyItemHovered() | bool | |
im.IsAnyItemActive() | bool | |
im.IsAnyItemFocused() | bool | |
im.GetItemID() | ImGuiID | |
im.GetItemRectMin() | ImVec2 | |
im.GetItemRectMax() | ImVec2 | |
im.GetItemRectSize() | ImVec2 | |
im.SetNextItemAllowOverlap() | - | |
im.SetItemDefaultFocus() | - | |
im.SetKeyboardFocusHere([offset]) | - |
Mouse / Input
| Function | Returns | Description |
|---|---|---|
im.IsMouseDown(button) | bool | |
im.IsMouseClicked(button, [repeat]) | bool | |
im.IsMouseReleased(button) | bool | |
im.IsMouseDoubleClicked(button) | bool | |
im.IsMouseHoveringRect(min, max, [clip]) | bool | |
im.IsMousePosValid([pos]) | bool | |
im.IsAnyMouseDown() | bool | |
im.GetMousePos() | ImVec2 | |
im.GetMousePosOnOpeningCurrentPopup() | ImVec2 | |
im.IsMouseDragging(button, [threshold]) | bool | |
im.GetMouseDragDelta([button], [threshold]) | ImVec2 | |
im.ResetMouseDragDelta([button]) | - | |
im.GetMouseCursor() | int | |
im.SetMouseCursor(cursor) | - | |
im.SetNextFrameWantCaptureMouse(want) | - | |
im.SetNextFrameWantCaptureKeyboard(want) | - |
Keys
| Function | Returns | Description |
|---|---|---|
im.IsKeyDown(key) | bool | |
im.IsKeyPressed(key, [repeat]) | bool | |
im.IsKeyReleased(key) | bool | |
im.GetKeyPressedAmount(key, repeatDelay, rate) | int |
Drag & Drop
| Function | Returns | Description |
|---|---|---|
im.BeginDragDropSource([flags]) | bool | |
im.SetDragDropPayload(type, data, size, [cond]) | bool | |
im.EndDragDropSource() | - | |
im.BeginDragDropTarget() | bool | |
im.AcceptDragDropPayload(type, [flags]) | payload | or nil |
im.EndDragDropTarget() | - | |
im.GetDragDropPayload() | payload |
Draw Lists (Custom Drawing)
Get a draw list via im.GetWindowDrawList(), im.GetBackgroundDrawList1(), or im.GetForegroundDrawList1().
| Function | Returns | Description |
|---|---|---|
im.ImDrawList_AddLine(dl, p1, p2, col, [thickness]) | - | |
im.ImDrawList_AddRect(dl, pMin, pMax, col, [rounding], [flags], [thickness]) | - | |
im.ImDrawList_AddRectFilled(dl, pMin, pMax, col, [rounding], [flags]) | - | |
im.ImDrawList_AddRectFilledMultiColor(dl, pMin, pMax, colUL, colUR, colBR, colBL) | - | |
im.ImDrawList_AddQuad(dl, p1, p2, p3, p4, col, [thickness]) | - | |
im.ImDrawList_AddQuadFilled(dl, p1, p2, p3, p4, col) | - | |
im.ImDrawList_AddTriangle(dl, p1, p2, p3, col, [thickness]) | - | |
im.ImDrawList_AddTriangleFilled(dl, p1, p2, p3, col) | - | |
im.ImDrawList_AddCircle(dl, center, radius, col, [numSegments], [thickness]) | - | |
im.ImDrawList_AddCircleFilled(dl, center, radius, col, [numSegments]) | - | |
im.ImDrawList_AddNgon(dl, center, radius, col, numSegments, [thickness]) | - | |
im.ImDrawList_AddNgonFilled(dl, center, radius, col, numSegments) | - | |
im.ImDrawList_AddText1(dl, pos, col, text) | - | |
im.ImDrawList_AddText2(dl, font, fontSize, pos, col, text) | - | |
im.ImDrawList_AddPolyline(dl, points, numPoints, col, flags, thickness) | - | |
im.ImDrawList_AddConvexPolyFilled(dl, points, numPoints, col) | - | |
im.ImDrawList_AddBezierCubic(dl, p1, p2, p3, p4, col, thickness, [segments]) | - | |
im.ImDrawList_AddBezierQuadratic(dl, p1, p2, p3, col, thickness, [segments]) | - | |
im.ImDrawList_AddImage(dl, texId, pMin, pMax, [uvMin], [uvMax], [col]) | - | |
im.ImDrawList_AddImageRounded(dl, texId, pMin, pMax, uvMin, uvMax, col, rounding, [flags]) | - |
Clip rects
| Function | Returns | Description |
|---|---|---|
im.ImDrawList_PushClipRect(dl, min, max, [intersectCurrent]) | - | |
im.ImDrawList_PopClipRect(dl) | - | |
im.ImDrawList_PushClipRectFullScreen(dl) | - |
| Function | Returns | Description |
|---|---|---|
im.ImDrawList_ChannelsSplit(dl, count) | - | |
im.ImDrawList_ChannelsSetCurrent(dl, n) | - | |
im.ImDrawList_ChannelsMerge(dl) | - |
Textures
| Function | Returns | Description |
|---|---|---|
im.ImTextureHandler(path) | handler | (.texId, .size) |
im.ImTextureHandlerIsCached(path) | bool | |
im.Image(texId, size, [uv0], [uv1], [tintCol], [borderCol]) | - |
Plots
⚠️ Data MUST be from
im.TableToArrayFloat(luaTable), NOT raw tables or ffi cdata.
| Function | Returns | Description |
|---|---|---|
im.PlotLines1(label, floatData, count, [offset], [overlayText], [scaleMin], [scaleMax], [graphSize], [stride]) | - | |
im.PlotHistogram1(label, floatData, count, [offset], [overlayText], [scaleMin], [scaleMax], [graphSize], [stride]) | - |
Correct usage:
local data = im.TableToArrayFloat({1, 2, 3, 4, 5}) -- Convert Lua table → plot-compatible format
local count = im.GetLengthArrayFloat(data) -- Get count (NOT #table)
im.PlotLines1("##graph", data, count, 0, "", 0, 10, im.ImVec2(300, 80))Utility
| Function | Returns | Description |
|---|---|---|
im.GetTime() | double | seconds since start |
im.GetFrameCount() | int | |
im.GetVersion() | string | |
im.GetIO() | ImGuiIO | |
im.GetMainViewport() | ImGuiViewport |
Clipboard
| Function | Returns | Description |
|---|---|---|
im.GetClipboardText() | string | |
im.SetClipboardText(text) | - |
Color conversion
| Function | Returns | Description |
|---|---|---|
im.ColorConvertFloat4ToU32(vec4) | u32 | |
im.ColorConvertU32ToFloat4(u32) | ImVec4 | |
im.ColorConvertRGBtoHSV(r, g, b) | h, s, v | |
im.ColorConvertHSVtoRGB(h, s, v) | r, g, b | |
im.GetColorU321(colIdx, [alphaMul]) | u32 | |
im.GetColorU322(vec4) | u32 |
Misc
| Function | Returns | Description |
|---|---|---|
im.ProgressBar(fraction, [size], [overlay]) | - | |
im.GetContentRegionAvailWidth() | float | wrapper for GetContentRegionAvail().x |
Helpers (BeamNG Custom)
| Function | Returns | Description |
|---|---|---|
im.ShowHelpMarker(desc, [sameLine]) | - | "(?)" with tooltip |
im.tooltip(message) | - | Tooltip if hovered |
im.HighlightText(label, highlightText) | - | Text with highlighted search matches |
im.HeaderText(text, [color]) | - | Large header text |
im.Knob(label, floatPtr, min, max, speed, fmt, variant, size, flags, steps) | - | |
im.KnobInt(label, intPtr, ...) | - |
Docking
| Function | Returns | Description |
|---|---|---|
im.DockSpace(id, [size], [flags], [windowClass]) | - | |
im.DockSpaceOverViewport([viewport], [flags], [windowClass]) | - | |
im.SetNextWindowDockID(dockId, [cond]) | - |
ImGuiListClipper (Large Lists)
| Function | Returns | Description |
|---|---|---|
im.ImGuiListClipper() | clipper | Create a list clipper |
im.ImGuiListClipper_Begin(clipper, itemCount, [itemHeight]) | - | Begin clipping |
im.ImGuiListClipper_Step(clipper) | bool | Advance to next range |
im.ImGuiListClipper_End(clipper) | - | End clipping |
Example usage:
local clipper = im.ImGuiListClipper()
im.ImGuiListClipper_Begin(clipper, itemCount, -1)
while im.ImGuiListClipper_Step(clipper) do
for i = clipper.DisplayStart, clipper.DisplayEnd - 1 do
im.Text("Item " .. i)
end
end
im.ImGuiListClipper_End(clipper)See Also
- ImGui Cheat Sheet - Quick visual reference
- ImGui Data Types - Pointer types and conversions
- ImGui Patterns - Common UI patterns
- ImGui Flags & Constants - All flag enumerations