fixed non dev compile

This commit is contained in:
Isaac0-dev 2024-10-22 20:54:11 +10:00
parent a81d8fde26
commit fd99cee674
2 changed files with 17 additions and 13 deletions

View file

@ -59,6 +59,7 @@ bool debug_context_within(enum DebugContext ctx) {
return sCtxDepth[ctx] > 0;
}
#ifdef DEVELOPMENT
void debug_context_set_time(enum DebugContext ctx, f64 time) {
if (ctx >= CTX_MAX) { return; }
sCtxTime[ctx] = time;
@ -67,4 +68,5 @@ void debug_context_set_time(enum DebugContext ctx, f64 time) {
f64 debug_context_get_time(enum DebugContext ctx) {
if (ctx >= CTX_MAX) { return 0.0; }
return sCtxTime[ctx];
}
}
#endif

View file

@ -38,15 +38,15 @@ struct DjuiCtxDisplay {
struct DjuiCtxDisplay *sCtxDisplay = NULL;
void djui_ctx_display_update(void) {
if (!configCtxProfiler || sCtxDisplay == NULL) { return; }
#ifdef DEVELOPMENT
if (!configCtxProfiler || sCtxDisplay == NULL) { return; }
// Time we have for a indivdual frame. If we exceed it. We are in the red.
f64 frameTime = 1.0 / 30.0;
s32 frameTimeMs = (s32)(frameTime * 1000000.0);
struct DjuiCtxEntry *topEntry = &sCtxDisplay->topEntry;
// If we've exceeded our available frame time. Make the top entry timing red - For dramatic effect.
// Otherwise. It's green!
if (debug_context_get_time(CTX_TOTAL) > frameTime) {
@ -54,19 +54,19 @@ void djui_ctx_display_update(void) {
} else {
djui_base_set_color(&topEntry->timing->base, 124, 252, 0, 240);
}
djui_text_set_text(topEntry->name, "FRAME");
char timing[32];
snprintf(timing, 32, "%05d", frameTimeMs);
djui_text_set_text(topEntry->timing, timing);
// Draw the counters.
for (s32 i = CTX_TOTAL; i < CTX_MAX; i++) {
struct DjuiCtxEntry *entry = &sCtxDisplay->entries[i];
const char *name = sDebugContextNames[i];
djui_text_set_text(entry->name, name);
// The timing is in microseconds.
s32 counterMs = (s32)(debug_context_get_time(i) * 1000000.0);
char timing[32];
@ -77,10 +77,12 @@ void djui_ctx_display_update(void) {
}
void djui_ctx_display_render(void) {
#ifdef DEVELOPMENT
if (!configCtxProfiler || sCtxDisplay == NULL) { return; }
djui_rect_render(&sCtxDisplay->base);
djui_base_render(&sCtxDisplay->base);
#endif
}
void djui_ctx_display_on_destroy(UNUSED struct DjuiBase* base) {
@ -94,7 +96,7 @@ void djui_ctx_display_initialize_entry(struct DjuiBase *base, struct DjuiCtxEntr
djui_base_set_size(&name->base, 1.0f, name->fontScale * 2);
djui_base_set_location(&name->base, 0, -name->fontScale / 3.0f + offset);
djui_base_set_color(&name->base, 255, 255, 255, 240);
struct DjuiText *timing = djui_text_create(base, "");
djui_text_set_alignment(timing, DJUI_HALIGN_RIGHT, DJUI_VALIGN_TOP);
djui_base_set_size_type(&timing->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
@ -119,10 +121,10 @@ void djui_ctx_display_create(void) {
{
f64 offset = 4.0;
djui_ctx_display_initialize_entry(base, &ctxDisplay->topEntry, offset);
offset += 35.0;
for (s32 i = CTX_TOTAL; i < CTX_MAX; i++) {
djui_ctx_display_initialize_entry(base, &ctxDisplay->entries[i], offset);
offset += 22.0;