# HG changeset patch # User Mike Becker # Date 1713470033 -7200 # Node ID f18dc427f86f8ecc7fa7ed18512c2ca7ec2cf213 # Parent e3cacdd636e41e558e223b64eef6bc3554b610f6 make use of the asc_window_active macro diff -r e3cacdd636e4 -r f18dc427f86f src/ascension/ui.h --- a/src/ascension/ui.h Tue Apr 16 22:20:17 2024 +0200 +++ b/src/ascension/ui.h Thu Apr 18 21:53:53 2024 +0200 @@ -31,7 +31,7 @@ #include "ui/text.h" #define asc_add_ui_node(node) \ - asc_scene_node_link(asc_context.active_window->ui, node) + asc_scene_node_link(asc_window_active->ui, node) #endif /* ASCENSION_UI_H */ diff -r e3cacdd636e4 -r f18dc427f86f src/ascension/window.h --- a/src/ascension/window.h Tue Apr 16 22:20:17 2024 +0200 +++ b/src/ascension/window.h Thu Apr 18 21:53:53 2024 +0200 @@ -55,6 +55,10 @@ AscSceneNode *ui; } AscWindow; +/** + * The currently active window in the context. + * @see asc_window_activate() + */ #define asc_window_active asc_context.active_window /** diff -r e3cacdd636e4 -r f18dc427f86f src/primitives.c --- a/src/primitives.c Tue Apr 16 22:20:17 2024 +0200 +++ b/src/primitives.c Thu Apr 18 21:53:53 2024 +0200 @@ -87,7 +87,7 @@ } void asc_primitives_draw_plane(void) { - AscMesh const *mesh = &(asc_context.active_window->glctx.primitives.plane); + AscMesh const *mesh = &(asc_window_active->glctx.primitives.plane); glBindVertexArray(mesh->vao); glDrawArrays(GL_TRIANGLE_STRIP, 0, mesh->vertices); } \ No newline at end of file diff -r e3cacdd636e4 -r f18dc427f86f src/scene.c --- a/src/scene.c Tue Apr 16 22:20:17 2024 +0200 +++ b/src/scene.c Thu Apr 18 21:53:53 2024 +0200 @@ -151,7 +151,7 @@ // Sprites // ------- // TODO: implement view matrix for 2D worlds - shader = &asc_context.active_window->glctx.shader.sprite.base; + shader = &asc_window_active->glctx.shader.sprite.base; glUseProgram(shader->id); glUniformMatrix4fv(shader->projection, 1, GL_FALSE, camera->projection); diff -r e3cacdd636e4 -r f18dc427f86f src/text.c --- a/src/text.c Tue Apr 16 22:20:17 2024 +0200 +++ b/src/text.c Thu Apr 18 21:53:53 2024 +0200 @@ -36,7 +36,7 @@ static void asc_text_draw(AscText const *node) { // Obtain shader - AscShaderSprite *shader = &asc_context.active_window->glctx.shader.sprite; + AscShaderSprite *shader = &asc_window_active->glctx.shader.sprite; // Upload model matrix glUniformMatrix4fv(shader->base.model, 1, diff -r e3cacdd636e4 -r f18dc427f86f src/window.c --- a/src/window.c Tue Apr 16 22:20:17 2024 +0200 +++ b/src/window.c Thu Apr 18 21:53:53 2024 +0200 @@ -85,7 +85,7 @@ if (asc_gl_context_initialize(&window->glctx, window->window, &settings->glsettings)) { window->ui = asc_scene_node_empty(); asc_dprintf("Window %u initialized", window->id); - asc_context.active_window = window; + asc_window_active = window; return window; } else { asc_dprintf("Creating GL context failed for window %u", window->id); @@ -102,8 +102,8 @@ if (window->id == 0) return; // this window cannot be active anymore - if (asc_context.active_window == window) { - asc_context.active_window = NULL; + if (asc_window_active == window) { + asc_window_active = NULL; } // destroy all scenes @@ -119,8 +119,8 @@ } // if another window was active, make the other context current again - if (asc_context.active_window != NULL) { - asc_gl_context_activate(&asc_context.active_window->glctx); + if (asc_window_active != NULL) { + asc_gl_context_activate(&asc_window_active->glctx); } // clean the data @@ -129,7 +129,7 @@ } void asc_window_sync(AscWindow* window) { - AscWindow *active_window = asc_context.active_window; + AscWindow *active_window = asc_window_active; if (window != active_window) { asc_window_activate(window); } @@ -159,5 +159,5 @@ void asc_window_activate(AscWindow *window) { asc_gl_context_activate(&window->glctx); - asc_context.active_window = (AscWindow *)window; + asc_window_active = (AscWindow *)window; }