diff options
Diffstat (limited to 'app.cpp')
-rw-r--r-- | app.cpp | 30 |
1 files changed, 19 insertions, 11 deletions
@@ -4,7 +4,7 @@ extern "C" { #include "memory.h" #include "plat.h" -extern int entrypoint(); +extern App* entrypoint(Arena* mem); } @@ -272,7 +272,22 @@ void app_destroy_vk_surface( } int main() { - return entrypoint(); + char* mem = (char*)malloc(app_memory_size); + Arena* arena = (Arena*)mem; + App* a; + mem += sizeof *arena; + init_arena(arena, mem, app_memory_size - sizeof *arena); + a = entrypoint(arena); + a->arena = arena; + a->on_init(); + while (a->running) { + a->begin(); + a->on_update(); + a->end(); + } + a->on_destroy(); + a->destroy(); + return 0; } #endif @@ -514,8 +529,9 @@ int WinMain( #endif -void App::init(const char* name) { +void App::init(const char* name, Arena* a) { dt = 0.0f; + arena = a; internal = (App_Internal*)arena_alloc( arena, sizeof *internal @@ -523,14 +539,6 @@ void App::init(const char* name) { internal->init(this, name); } -void* App::alloc(int size, Arena*& arena) { - char* mem = (char*)malloc(app_memory_size); - arena = (Arena*)mem; - mem += sizeof *arena; - init_arena(arena, mem, app_memory_size - sizeof *arena); - return arena_alloc(arena, size); -} - void App::destroy() { free(arena); } |