Skip to content

Engine → Renderer → debug_draw.h

debug_draw

Syntax

class CONJURE_API debug_draw

Constructors

AccessSignatureDescription
publicdebug_draw();

Important

Copy constructor and assignment has been deleted.

Destructors

AccessSignatureDescription
public~debug_draw();

Variables

AccessNameTypeDefaultDescription
privatemImmediatedebug_draw_buffer{}
privatemImmediateTextstd::vector<text_record>{}
privatemImmediateTextBytesstd::vector<char>{}
privatemMutexmutable std::mutex{}
privatemStatsdebug_draw_stats{}
privatemTimedstd::vector<timed_entry>{}
privatemTimedTextstd::vector<text_record>{}
privatemTimedTextBytesstd::vector<char>{}

Functions

Public

append_to

void append_to(
    debug_draw_buffer &target);

append_to(target, view) without a view: the shapes are appended, this frame's text is dropped and counted, and the timed text is kept but not drawn.

void append_to(
    debug_draw_buffer &target,
    const debug_text_view &view);

Appends the immediate shapes and every live timed shape to target, expands this frame's text and every live timed text against view into lines there, and clears the immediate shapes and text. Without a view (see debug_text_view) this frame's text is dropped and counted in textDroppedWithoutView and the timed text is not drawn this time. Text anchored at or behind a perspective camera's eye draws nothing. Records the vertices it added in lastAppendVertices.

axes

void axes(
    const math::mat4 &worldFromLocal,
    f32 length = 1.0f,
    f32 durationSeconds = 0.0f,
    debug_depth depth = debug_depth::TESTED);

Axis lines (debug_draw_buffer::axes) that live this frame (durationSeconds not positive, NaN included) or for durationSeconds.

box

void box(
    const math::aabb &box,
    const math::vec4 &colour,
    f32 durationSeconds = 0.0f,
    debug_depth depth = debug_depth::TESTED);

A box (debug_draw_buffer::box) that lives this frame (durationSeconds not positive, NaN included) or for durationSeconds.

clear

void clear();

Drops every immediate and timed shape and text; the counters are kept.

line

void line(
    const math::vec3 &a,
    const math::vec3 &b,
    const math::vec4 &colour,
    f32 durationSeconds = 0.0f,
    debug_depth depth = debug_depth::TESTED);

A line that lives this frame (durationSeconds not positive, NaN included) or for durationSeconds.

sphere

void sphere(
    const math::vec3 &centre,
    f32 radius,
    const math::vec4 &colour,
    f32 durationSeconds = 0.0f,
    debug_depth depth = debug_depth::TESTED);

A sphere (debug_draw_buffer::sphere) that lives this frame (durationSeconds not positive, NaN included) or for durationSeconds.

stats

[[nodiscard]] debug_draw_stats stats() const;

The text counters and the size of the last append_to.

submit

void submit(
    const debug_draw_buffer &shape,
    f32 durationSeconds = 0.0f);

Adds a prepared buffer as an immediate (durationSeconds not positive, NaN included) or timed entry.

text

void text(
    const math::vec3 &anchor,
    std::string_view utf8,
    const math::vec4 &colour,
    f32 durationSeconds = 0.0f,
    debug_depth depth = debug_depth::OVERLAY);

Debug text that lives this frame (durationSeconds not positive, NaN included) or for durationSeconds, drawn by append_to as lines of the built-in stroke font in the plane of the view's camera: each line centred horizontally on anchor, the first baseline through it and each line feed starting a line below, DEBUG_TEXT_PIXEL_HEIGHT times the view's UI scale pixels of its viewportHeightPixels high at any distance. OVERLAY by default, so a label stays visible inside what it names. Text longer than MAX_DEBUG_TEXT_BYTES is cut at a code point (textTruncated); a call that would take the queued text over MAX_DEBUG_TEXT_ARENA_BYTES is dropped (textDroppedArenaFull). Empty text queues and counts nothing. Each malformed UTF-8 byte draws '?'.

tick

void tick(
    f32 deltaSeconds);

Ages the timed shapes and text and drops the expired ones; the bytes of expired text are reclaimed (the timed arena is compacted and keeps its capacity).

timed_entry_count

[[nodiscard]] usize timed_entry_count() const;

Number of timed shapes still alive (timed text is not counted).

Private

add_timed

void add_timed(
    debug_draw_buffer &&shape,
    f32 durationSeconds);

expand_text

static void expand_text(
    debug_draw_buffer &target,
    const text_record &record,
    std::string_view utf8,
    const debug_text_view &view);