Vector Types
ImVec2
2D vector used to store positions, sizes, etc.
Example:
Add #define IMGUI_DEFINE_MATH_OPERATORS before including imgui.h to access math operators for ImVec2 and ImVec4.
With Math Operators:
ImVec4
4D vector used to store clipping rectangles, colors, etc.
Example:
Scalar Types
Integer Types
Example:
ImGuiID
A unique ID used by widgets, typically the result of hashing a stack of strings.
Example:
Character Types
Drawing Types
ImDrawIdx
Vertex index. Can be overridden in imconfig.h to use 32-bit indices:
To use 16-bit indices with large meshes (64K+ vertices), backend needs to set io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset.
ImDrawVert
Vertex structure used for rendering. Total size: 20 bytes by default.
Example:
You can override the vertex format by defining IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT in imconfig.h.
Texture Types
ImTextureID
Backend-specific, low-level identifier for a texture. Can be overridden in imconfig.h:
Example:
ImTextureRef
Higher-level texture identifier that can reference either:
- A texture owned by the font atlas (
_TexData)
- A user-provided texture (
_TexID)
Example:
Color Types
ImColor (Obsolete)
ImColor is obsolete. Please avoid using it. Use ImU32 or ImVec4 directly instead.
Modern alternative:
Direction Enum
Cardinal direction.
Example:
Sort Direction
Sorting direction for tables.
Common Patterns
Vector Arithmetic (with IMGUI_DEFINE_MATH_OPERATORS)
Color Conversions
Rectangle Math
See Also
- Colors - Color utilities and conversion
- Draw List - Using vectors in drawing commands