1.1 --- a/src/window.c Sun Jan 21 14:01:27 2024 +0100 1.2 +++ b/src/window.c Tue Jan 23 21:34:12 2024 +0100 1.3 @@ -61,6 +61,10 @@ 1.4 settings->title = "Ascended Window"; 1.5 } 1.6 1.7 +static void asc_window_init_scenes(AscWindow *window) { 1.8 + asc_scene_init(&window->ui); 1.9 +} 1.10 + 1.11 AscWindow *asc_window_initialize(unsigned int index, AscWindowSettings const *settings) { 1.12 if (index >= ASC_MAX_WINDOWS) { 1.13 asc_error("Maximum number of windows exceeded."); 1.14 @@ -123,6 +127,7 @@ 1.15 1.16 asc_dprintf("Window %u initialized", window->id); 1.17 if (asc_primitives_init(&window->primitives)) { 1.18 + asc_window_init_scenes(window); 1.19 asc_context.active_window = window; 1.20 return window; 1.21 } else { 1.22 @@ -152,6 +157,9 @@ 1.23 asc_context.active_window = NULL; 1.24 } 1.25 1.26 + // destroy all scenes 1.27 + asc_scene_destroy(&window->ui); 1.28 + 1.29 // release context related data (we have to make the GL context current for this) 1.30 SDL_GL_MakeCurrent(window->window, window->glctx); 1.31 asc_primitives_destroy(&window->primitives); 1.32 @@ -180,10 +188,18 @@ 1.33 if (window != active_window) { 1.34 asc_window_activate(window); 1.35 } 1.36 - SDL_GL_SwapWindow(window->window); 1.37 + 1.38 + // Clear viewport for new frame 1.39 glViewport(0, 0, window->dimensions.width, window->dimensions.height); 1.40 glClearColor(0.0f, 0.0f, 0.0f, 1.0f); 1.41 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 1.42 + 1.43 + // Draw the UI 1.44 + asc_scene_draw(&window->ui); 1.45 + 1.46 + // Swap Buffers 1.47 + SDL_GL_SwapWindow(window->window); 1.48 + 1.49 if (window != active_window) { 1.50 asc_window_activate(active_window); 1.51 }