Thu, 18 Apr 2024 21:53:53 +0200
make use of the asc_window_active macro
src/ascension/ui.h | file | annotate | diff | comparison | revisions | |
src/ascension/window.h | file | annotate | diff | comparison | revisions | |
src/primitives.c | file | annotate | diff | comparison | revisions | |
src/scene.c | file | annotate | diff | comparison | revisions | |
src/text.c | file | annotate | diff | comparison | revisions | |
src/window.c | file | annotate | diff | comparison | revisions |
--- 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 */
--- 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 /**
--- 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
--- 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);
--- 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,
--- 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; }