From 1b215b8265f6461ec57ca79f72dcc9585c09cf16 Mon Sep 17 00:00:00 2001 From: cinnaboot Date: Sun, 24 Jul 2022 10:16:07 -0400 Subject: [PATCH] add more gooey elements for other memory arenas --- src/gooey.cpp | 41 ++++++++++++++++++++++++++++++++--------- src/gooey.h | 3 ++- src/main.cpp | 2 +- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/gooey.cpp b/src/gooey.cpp index 4d1a7df..8b3fdb9 100644 --- a/src/gooey.cpp +++ b/src/gooey.cpp @@ -18,7 +18,7 @@ const int H_FLAGS = ImGuiTreeNodeFlags_DefaultOpen; // forward declarations void drawSimulationWindow(bool& running, u64 sim_time_ms, float& sim_speed); -void drawMemoryWindow(MemoryArena* arena); +void drawMemoryWindow(MemoryArena* game_arena, RenderState* rs); void drawOrbitWindow(GameState* gs); void drawEllipseParameters(EllipseParameters& ep); void drawGravitationalBody(GravBody& body); @@ -63,7 +63,7 @@ gooProcessEvent(SDL_Event& e) } void -gooDraw(SDL_Window* window, GameState* gs) +gooDraw(SDL_Window* window, GameState* gs, RenderState* rs) { ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplSDL2_NewFrame(window); @@ -76,7 +76,7 @@ gooDraw(SDL_Window* window, GameState* gs) Begin("Gooey"); drawSimulationWindow(gs->running, gs->sim_time_ms, gs->sim_speed); - drawMemoryWindow(gs->arena); + drawMemoryWindow(gs->arena, rs); Separator(); // FIXME: split up orbit window into function calls here @@ -116,18 +116,41 @@ void drawSimulationWindow(bool& running, u64 sim_time_ms, float& sim_speed) InputFloat("sim speed", &sim_speed, 0.1, 4.0, "%.1f"); } -void drawMemoryWindow(MemoryArena* arena) +void drawMemoryWindow(MemoryArena* game_arena, RenderState* rs) { - BeginChild("memory", ImVec2(G_WIDTH - 20, 50), true); + MemoryArena* rg_arena = rs->rg_arena; + MemoryArena* asset_arena = rs->assets.arena; + + BeginChild("memory", ImVec2(G_WIDTH - 20, 125), true); Text("GameState Memory Arena"); - float freeMB = (float) arena->free_size / (float) (1024 * 1024); - float maxMB = (float) arena->max_size / (float) (1024 * 1024); + float freeMB = (float) game_arena->free_size / (float) (1024 * 1024); + float maxMB = (float) game_arena->max_size / (float) (1024 * 1024); float usedMB = maxMB - freeMB; Text("%.2f MB", usedMB); SameLine(); ProgressBar(usedMB / maxMB, ImVec2(100, 15)); SameLine(); Text("%.2f MB", maxMB); + + Text("RenderGroup Memory Arena"); + freeMB = (float) rg_arena->free_size / (float) (1024 * 1024); + maxMB = (float) rg_arena->max_size / (float) (1024 * 1024); + usedMB = maxMB - freeMB; + Text("%.2f MB", usedMB); + SameLine(); + ProgressBar(usedMB / maxMB, ImVec2(100, 15)); + SameLine(); + Text("%.2f MB", maxMB); + + Text("Asset Memory Arena"); + freeMB = (float) asset_arena->free_size / (float) (1024 * 1024); + maxMB = (float) asset_arena->max_size / (float) (1024 * 1024); + usedMB = maxMB - freeMB; + Text("%.2f MB", usedMB); + SameLine(); + ProgressBar(usedMB / maxMB, ImVec2(100, 15)); + SameLine(); + Text("%.2f MB", maxMB); EndChild(); } @@ -135,7 +158,7 @@ void drawOrbitWindow(GameState* gs) { Text("Orbit Selection"); - BeginChild("orbit selection", ImVec2(G_WIDTH - 20, 70), true); + BeginChild("orbit selection", ImVec2(G_WIDTH - 20, 55), true); static u32 selected = UINT_MAX; for (u32 i = 0; i < gs->num_orbits; i++) { @@ -159,7 +182,7 @@ void drawOrbitWindow(GameState* gs) && gs->orbits[selected].in_use) { TwoBodySystem& sys = gs->orbits[selected].system; - BeginChild("orbit details", ImVec2(G_WIDTH - 20, 500), true); + BeginChild("orbit details", ImVec2(G_WIDTH - 20, 450), true); Text("Selected Orbit#: %d", selected); //Text("Orbital Period: %.2fs", sys.orbital_period); drawSystemWindow(sys); diff --git a/src/gooey.h b/src/gooey.h index 70bcb66..bc3e827 100644 --- a/src/gooey.h +++ b/src/gooey.h @@ -5,6 +5,7 @@ #include "game.h" #include "orbits.h" +#include "tangerine.h" bool @@ -17,4 +18,4 @@ bool gooProcessEvent(SDL_Event &e); void -gooDraw(SDL_Window* window, GameState* gs); +gooDraw(SDL_Window* window, GameState* gs, RenderState* rs); diff --git a/src/main.cpp b/src/main.cpp index dd55a08..ec10266 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -327,7 +327,7 @@ void postFrameCallback(RenderState* rs, void* user_data = nullptr) { assert(user_data != nullptr); - gooDraw(rs->handles.window, (GameState*) user_data); + gooDraw(rs->handles.window, (GameState*) user_data, rs); } #define DEFAULT_SIM_SPEED 500