Skip to content

gizmos

The gizmos package provides a suite of immediate-mode visual debugging tools designed to help easily visualize game state, math, and spatial logic.

Features:

  • Zero Overhead in Release: Gizmo rendering commands are strictly limited to debug builds.
  • Primitive Visualization: Quickly draw points, lines, arrows, rectangles, and circles (both solid and wireframe) to debug hitboxes, velocity vectors, raycasts, and triggers.
  • Coordinate Spaces: Supports specifying DebugSpace to easily decouple UI-space debugging from World-space debugging.

You can call draw* functions from anywhere within your game loop. These calls are batched into a queue and automatically dispatched to the renderer when flush is called internally at the end of the frame.


DebugSpace :: enum {
World,
Screen,
}

Space in which the debug visual should be rendered.


drawArrow :: proc (
start: gmath.Vector2,
end: gmath.Vector2,
color := colors.BLUE,
space := DebugSpace.World,
)

Draws a debug arrow pointing from start to end. Only rendered in debug builds. Matches drawArrow


drawCircle :: proc (
center: gmath.Vector2,
radius: f32,
color := gmath.Color{0, 1, 0, 0.5},
space := DebugSpace.World,
)

Draws a debug circle. Only rendered in debug builds. Matches drawCircle


drawCircleLines :: proc (
center: gmath.Vector2,
radius: f32,
color := colors.GREEN,
space := DebugSpace.World,
)

Draws a debug circle outline. Only rendered in debug builds. Matches drawCircleLines


drawGrid :: proc (
cellSize: f32 = 32.0,
lines: int = 10, // number of lines in each direction from center
color := gmath.Color{1, 1, 1, 0.2},
space := DebugSpace.World,
)

Draws a grid centered at (0, 0). Helpful for visualizing scale, alignment and spatial partitioning buckets.


drawLine :: proc (
start: gmath.Vector2,
end: gmath.Vector2,
color := colors.RED,
space := DebugSpace.World,
)

Draws a debug line between start and end. Only rendered in debug builds. Matches drawLine


drawPoint :: proc (
position: gmath.Vector2,
size: f32 = 5.0,
color := colors.GREEN,
space := DebugSpace.World,
)

Draws a small cross at a specific position to mark a point. Only rendered in debug builds.


drawRectangle :: proc (
rectangle: gmath.Rectangle,
color := gmath.Color{1, 0, 0, 0.5},
space := DebugSpace.World,
)

Draws a debug rectangle. Only rendered in debug builds. Matches drawRectangle


drawRectangleLines :: proc (
rectangle: gmath.Rectangle,
color := colors.RED,
space := DebugSpace.World,
)

Draws a debug rectangle outline. Only rendered in debug builds. Matches drawRectangleLines


drawText :: proc (
position: gmath.Vector2,
text: string,
color := colors.WHITE,
size: uint = 12,
pivot := gmath.Pivot.bottomLeft,
space := DebugSpace.World,
)

Draws debug text at a specific position. Only rendered in debug builds.


flush :: proc ()

Flushes all queued gizmos to the renderer. Called at the end of the frame internally in main.odin.