Blitz3D+ Command Reference

ClearDebugDraw

Parameters

None.

Description

Throws away all debug shapes queued for the next RenderWorld.

Every Debug command (DebugLine, DebugBox, DebugGrid, DebugEntityBounds and the rest) adds lines to one shared queue that the next RenderWorld draws and then clears automatically. ClearDebugDraw empties that queue early, before it is drawn.

Because the queue already clears itself after every RenderWorld, you do not need this for normal frame-by-frame drawing. It earns its keep when shapes have been queued this frame that you now decide not to show: the player switched your debug overlay off mid-frame, or a helper function queued its markers before your code noticed the toggle. One call and the frame renders clean.

It also resets the overflow flag, so the "65,536-line debug-draw limit" warning can be reported again if the queue fills up later.

Note that ClearDebugDraw only affects queued one-frame debug shapes. Persistent line-list entities made with CreateLineList are untouched - clear those per list with ClearLines.

Requires Extended mode.

See also: DebugLine, DebugGrid, DebugEntityBounds, ClearLines, RenderWorld.

Example

; ClearDebugDraw Example
; ----------------------
; Requires Extended mode.

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

camera=CreateCamera()
PositionEntity camera,0,3,-9

light=CreateLight()
RotateEntity light,45,45,0

; A drone circling the arena with a full debug overlay
drone=CreateCube()
ScaleEntity drone,0.5,0.5,0.5
EntityColor drone,80,200,255

While Not KeyDown(1)

    ; The drone circles while the overlay tracks it
    angle#=angle+1.5
    PositionEntity drone,4*Cos(angle),1.5+Sin(angle*3),4*Sin(angle)

    ; Queue several debug shapes for the next RenderWorld
    DebugGrid 12,1,0,90,90,90
    DebugSphere EntityX(drone),EntityY(drone),EntityZ(drone),1,16,255,220,0
    DebugLine 0,0,0,EntityX(drone),EntityY(drone),EntityZ(drone),255,80,80

    ; Holding Space discards everything queued above before it is drawn
    If KeyDown(57) Then ClearDebugDraw

    ; Arrow keys move the camera
    If KeyDown(200) Then MoveEntity camera,0,0,0.1
    If KeyDown(208) Then MoveEntity camera,0,0,-0.1
    If KeyDown(203) Then TurnEntity camera,0,1,0
    If KeyDown(205) Then TurnEntity camera,0,-1,0

    RenderWorld

    Text 0,0,"Arrow keys: move camera   Hold Space: ClearDebugDraw   Esc: exit"
    If KeyDown(57) Then Text 0,20,"ClearDebugDraw dropped this frame's queued shapes" Else Text 0,20,"Grid, sphere and line are queued fresh every frame"

    Flip

Wend

End

Index