push debug info to temp arena
This commit is contained in:
parent
452e922e23
commit
ff3fbecc10
@ -46,7 +46,7 @@ INLINE void arena_pop_to(struct arena *arena, u64 pos)
|
||||
arena->pos = pos;
|
||||
}
|
||||
|
||||
INLINE struct temp_arena arena_push_temp(struct arena *arena)
|
||||
INLINE struct temp_arena arena_temp_begin(struct arena *arena)
|
||||
{
|
||||
struct temp_arena t;
|
||||
t.arena = arena;
|
||||
@ -54,7 +54,7 @@ INLINE struct temp_arena arena_push_temp(struct arena *arena)
|
||||
return t;
|
||||
}
|
||||
|
||||
INLINE void arena_pop_temp(struct temp_arena temp)
|
||||
INLINE void arena_temp_end(struct temp_arena temp)
|
||||
{
|
||||
arena_pop_to(temp.arena, temp.start_pos);
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ INLINE struct temp_arena _scratch_begin(struct arena *potential_conflict)
|
||||
scratch = &ctx->arenas[1];
|
||||
}
|
||||
|
||||
struct temp_arena temp = arena_push_temp(scratch);
|
||||
struct temp_arena temp = arena_temp_begin(scratch);
|
||||
|
||||
#if RTC
|
||||
if (ctx->scratch_id_stack_count >= ARRAY_COUNT(ctx->scratch_id_stack)) {
|
||||
@ -71,7 +71,7 @@ INLINE struct temp_arena _scratch_begin_no_conflict(void)
|
||||
{
|
||||
struct scratch_context *ctx = sys_thread_get_scratch_context();
|
||||
struct arena *scratch = &ctx->arenas[0];
|
||||
struct temp_arena temp = arena_push_temp(scratch);
|
||||
struct temp_arena temp = arena_temp_begin(scratch);
|
||||
|
||||
#if RTC
|
||||
if (ctx->scratch_id_stack_count >= ARRAY_COUNT(ctx->scratch_id_stack)) {
|
||||
@ -100,7 +100,7 @@ INLINE void scratch_end(struct temp_arena scratch_temp)
|
||||
}
|
||||
#endif
|
||||
|
||||
arena_pop_temp(scratch_temp);
|
||||
arena_temp_end(scratch_temp);
|
||||
}
|
||||
|
||||
INLINE void scratch_end_and_decommit(struct temp_arena scratch_temp)
|
||||
|
||||
@ -187,9 +187,6 @@ abort:
|
||||
if (!success) {
|
||||
logf_error("Error loading sheet \"%F\": %F", FMT_STR(path), FMT_STR(error_msg));
|
||||
|
||||
/* TODO: Return default sheet */
|
||||
/* Generate purple & black image */
|
||||
|
||||
/* Store */
|
||||
struct sheet *sheet = NULL;
|
||||
{
|
||||
|
||||
28
src/user.c
28
src/user.c
@ -676,6 +676,8 @@ INTERNAL void user_update(void)
|
||||
|
||||
/* Debug draw info */
|
||||
if (L.debug_draw && !is_camera) {
|
||||
struct temp_arena temp = arena_temp_begin(scratch.arena);
|
||||
|
||||
struct font *disp_font = font_load_async(STR("res/fonts/fixedsys.ttf"), 12.0f);
|
||||
if (disp_font) {
|
||||
struct xform xf = ent->world_xform;
|
||||
@ -698,7 +700,7 @@ INTERNAL void user_update(void)
|
||||
"velocity: (%F, %F)\n"
|
||||
"acceleration: (%F, %F)\n"
|
||||
);
|
||||
struct string text = string_format(scratch.arena, fmt,
|
||||
struct string text = string_format(temp.arena, fmt,
|
||||
FMT_STR(disp_name),
|
||||
FMT_FLOAT((f64)trs.t.x), FMT_FLOAT((f64)trs.t.y),
|
||||
FMT_FLOAT((f64)trs.s.x), FMT_FLOAT((f64)trs.s.y),
|
||||
@ -713,6 +715,8 @@ INTERNAL void user_update(void)
|
||||
|
||||
debug_draw_xform(ent->world_xform);
|
||||
debug_draw_movement(ent);
|
||||
|
||||
arena_temp_end(temp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -731,36 +735,40 @@ INTERNAL void user_update(void)
|
||||
|
||||
/* Debug draw info */
|
||||
if (L.debug_draw) {
|
||||
struct temp_arena temp = arena_temp_begin(scratch.arena);
|
||||
|
||||
f32 spacing = 20;
|
||||
struct v2 pos = V2(10, 8);
|
||||
struct font *font = font_load(STR("res/fonts/fixedsys.ttf"), 12.0f);
|
||||
|
||||
draw_text(L.ui_canvas, font, pos, string_format(scratch.arena, STR("time: %F"), FMT_FLOAT((f64)L.time)));
|
||||
draw_text(L.ui_canvas, font, pos, string_format(temp.arena, STR("time: %F"), FMT_FLOAT((f64)L.time)));
|
||||
pos.y += spacing;
|
||||
|
||||
draw_text(L.ui_canvas, font, pos, string_format(scratch.arena, STR("screen_size: (%F, %F)"), FMT_FLOAT((f64)L.screen_size.x), FMT_FLOAT((f64)L.screen_size.y)));
|
||||
draw_text(L.ui_canvas, font, pos, string_format(temp.arena, STR("screen_size: (%F, %F)"), FMT_FLOAT((f64)L.screen_size.x), FMT_FLOAT((f64)L.screen_size.y)));
|
||||
pos.y += spacing;
|
||||
|
||||
draw_text(L.ui_canvas, font, pos, string_format(scratch.arena, STR("screen_center: (%F, %F)"), FMT_FLOAT((f64)L.screen_center.x), FMT_FLOAT((f64)L.screen_center.y)));
|
||||
draw_text(L.ui_canvas, font, pos, string_format(temp.arena, STR("screen_center: (%F, %F)"), FMT_FLOAT((f64)L.screen_center.x), FMT_FLOAT((f64)L.screen_center.y)));
|
||||
pos.y += spacing;
|
||||
|
||||
draw_text(L.ui_canvas, font, pos, string_format(scratch.arena, STR("screen_mouse: (%F, %F)"), FMT_FLOAT((f64)L.screen_mouse.x), FMT_FLOAT((f64)L.screen_mouse.y)));
|
||||
draw_text(L.ui_canvas, font, pos, string_format(temp.arena, STR("screen_mouse: (%F, %F)"), FMT_FLOAT((f64)L.screen_mouse.x), FMT_FLOAT((f64)L.screen_mouse.y)));
|
||||
pos.y += spacing;
|
||||
|
||||
draw_text(L.ui_canvas, font, pos, string_format(scratch.arena, STR("world_view.center: (%F, %F)"), FMT_FLOAT((f64)L.world_view.center.x), FMT_FLOAT((f64)L.world_view.center.y)));
|
||||
draw_text(L.ui_canvas, font, pos, string_format(temp.arena, STR("world_view.center: (%F, %F)"), FMT_FLOAT((f64)L.world_view.center.x), FMT_FLOAT((f64)L.world_view.center.y)));
|
||||
pos.y += spacing;
|
||||
|
||||
draw_text(L.ui_canvas, font, pos, string_format(scratch.arena, STR("world_view.rot: %F"), FMT_FLOAT((f64)L.world_view.rot)));
|
||||
draw_text(L.ui_canvas, font, pos, string_format(temp.arena, STR("world_view.rot: %F"), FMT_FLOAT((f64)L.world_view.rot)));
|
||||
pos.y += spacing;
|
||||
|
||||
draw_text(L.ui_canvas, font, pos, string_format(scratch.arena, STR("world_view.zoom: %F"), FMT_FLOAT((f64)L.world_view.zoom)));
|
||||
draw_text(L.ui_canvas, font, pos, string_format(temp.arena, STR("world_view.zoom: %F"), FMT_FLOAT((f64)L.world_view.zoom)));
|
||||
pos.y += spacing;
|
||||
|
||||
draw_text(L.ui_canvas, font, pos, string_format(scratch.arena, STR("world_mouse: (%F, %F)"), FMT_FLOAT((f64)world_mouse.x), FMT_FLOAT((f64)world_mouse.y)));
|
||||
draw_text(L.ui_canvas, font, pos, string_format(temp.arena, STR("world_mouse: (%F, %F)"), FMT_FLOAT((f64)world_mouse.x), FMT_FLOAT((f64)world_mouse.y)));
|
||||
pos.y += spacing;
|
||||
|
||||
draw_text(L.ui_canvas, font, pos, string_format(scratch.arena, STR("debug_camera: %F"), FMT_STR(L.debug_camera ? STR("true") : STR("false"))));
|
||||
draw_text(L.ui_canvas, font, pos, string_format(temp.arena, STR("debug_camera: %F"), FMT_STR(L.debug_camera ? STR("true") : STR("false"))));
|
||||
pos.y += spacing;
|
||||
|
||||
arena_temp_end(temp);
|
||||
}
|
||||
|
||||
/* Push game cmds */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user