From 50063211bd217c925b8629a6b4616f84fb3b2f85 Mon Sep 17 00:00:00 2001 From: Nathan O Date: Thu, 17 Feb 2022 12:39:17 -0500 Subject: [PATCH] Print vertex buffer size to stdout - The vertex buffer is FAR larger than the L-system itself, so I figured it may be useful status information, to keep an eye on prior to iterating the L-system again. --- l_system_3d.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/l_system_3d.c b/l_system_3d.c index 5f8df70..269f0c2 100644 --- a/l_system_3d.c +++ b/l_system_3d.c @@ -216,6 +216,13 @@ static void ReloadConfig(ApplicationState *s) { printf("Config updated OK.\n"); } +static void PrintMemoryUsage(ApplicationState *s) { + float vbo_size_mb = ToMB(sizeof(MeshVertex) * s->mesh->vertex_count); + printf("L-system size is now %.02f MB.\n", ToMB(s->l_system_length)); + printf("Drawing %u vertices, taking %.02f MB.\n", + (unsigned) s->mesh->vertex_count, vbo_size_mb); +} + static int ProcessInputs(ApplicationState *s) { int pressed; if (glfwGetKey(s->window, GLFW_KEY_ESCAPE) == GLFW_PRESS) { @@ -229,7 +236,7 @@ static int ProcessInputs(ApplicationState *s) { // Nothing pressed -> up pressed s->key_pressed_tmp = GLFW_KEY_UP; if (!(IncreaseIterations(s) && GenerateVertices(s))) return 0; - printf("New L-system length: %.02f MB.\n", ToMB(s->l_system_length)); + PrintMemoryUsage(s); } else if ((s->key_pressed_tmp == GLFW_KEY_UP) && !pressed) { // Up pressed -> up released s->key_pressed_tmp = 0; @@ -239,7 +246,7 @@ static int ProcessInputs(ApplicationState *s) { // Nothing pressed -> down pressed s->key_pressed_tmp = GLFW_KEY_DOWN; if (!(DecreaseIterations(s) && GenerateVertices(s))) return 0; - printf("New L-system length: %.02f MB.\n", ToMB(s->l_system_length)); + PrintMemoryUsage(s); } else if ((s->key_pressed_tmp == GLFW_KEY_DOWN) && !pressed) { // Down pressed -> down released s->key_pressed_tmp = 0;