make use of the asc_window_active macro

Thu, 18 Apr 2024 21:53:53 +0200

author
Mike Becker <universe@uap-core.de>
date
Thu, 18 Apr 2024 21:53:53 +0200
changeset 64
f18dc427f86f
parent 63
e3cacdd636e4
child 65
9c44c55d327a

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
     1.1 --- a/src/ascension/ui.h	Tue Apr 16 22:20:17 2024 +0200
     1.2 +++ b/src/ascension/ui.h	Thu Apr 18 21:53:53 2024 +0200
     1.3 @@ -31,7 +31,7 @@
     1.4  #include "ui/text.h"
     1.5  
     1.6  #define asc_add_ui_node(node) \
     1.7 -    asc_scene_node_link(asc_context.active_window->ui, node)
     1.8 +    asc_scene_node_link(asc_window_active->ui, node)
     1.9  
    1.10  #endif /* ASCENSION_UI_H */
    1.11  
     2.1 --- a/src/ascension/window.h	Tue Apr 16 22:20:17 2024 +0200
     2.2 +++ b/src/ascension/window.h	Thu Apr 18 21:53:53 2024 +0200
     2.3 @@ -55,6 +55,10 @@
     2.4      AscSceneNode *ui;
     2.5  } AscWindow;
     2.6  
     2.7 +/**
     2.8 + * The currently active window in the context.
     2.9 + * @see asc_window_activate()
    2.10 + */
    2.11  #define asc_window_active asc_context.active_window
    2.12  
    2.13  /**
     3.1 --- a/src/primitives.c	Tue Apr 16 22:20:17 2024 +0200
     3.2 +++ b/src/primitives.c	Thu Apr 18 21:53:53 2024 +0200
     3.3 @@ -87,7 +87,7 @@
     3.4  }
     3.5  
     3.6  void asc_primitives_draw_plane(void) {
     3.7 -    AscMesh const *mesh = &(asc_context.active_window->glctx.primitives.plane);
     3.8 +    AscMesh const *mesh = &(asc_window_active->glctx.primitives.plane);
     3.9      glBindVertexArray(mesh->vao);
    3.10      glDrawArrays(GL_TRIANGLE_STRIP, 0, mesh->vertices);
    3.11  }
    3.12 \ No newline at end of file
     4.1 --- a/src/scene.c	Tue Apr 16 22:20:17 2024 +0200
     4.2 +++ b/src/scene.c	Thu Apr 18 21:53:53 2024 +0200
     4.3 @@ -151,7 +151,7 @@
     4.4      // Sprites
     4.5      // -------
     4.6      // TODO: implement view matrix for 2D worlds
     4.7 -    shader = &asc_context.active_window->glctx.shader.sprite.base;
     4.8 +    shader = &asc_window_active->glctx.shader.sprite.base;
     4.9      glUseProgram(shader->id);
    4.10      glUniformMatrix4fv(shader->projection, 1,
    4.11                         GL_FALSE, camera->projection);
     5.1 --- a/src/text.c	Tue Apr 16 22:20:17 2024 +0200
     5.2 +++ b/src/text.c	Thu Apr 18 21:53:53 2024 +0200
     5.3 @@ -36,7 +36,7 @@
     5.4  
     5.5  static void asc_text_draw(AscText const *node) {
     5.6      // Obtain shader
     5.7 -    AscShaderSprite *shader = &asc_context.active_window->glctx.shader.sprite;
     5.8 +    AscShaderSprite *shader = &asc_window_active->glctx.shader.sprite;
     5.9  
    5.10      // Upload model matrix
    5.11      glUniformMatrix4fv(shader->base.model, 1,
     6.1 --- a/src/window.c	Tue Apr 16 22:20:17 2024 +0200
     6.2 +++ b/src/window.c	Thu Apr 18 21:53:53 2024 +0200
     6.3 @@ -85,7 +85,7 @@
     6.4      if (asc_gl_context_initialize(&window->glctx, window->window, &settings->glsettings)) {
     6.5          window->ui = asc_scene_node_empty();
     6.6          asc_dprintf("Window %u initialized", window->id);
     6.7 -        asc_context.active_window = window;
     6.8 +        asc_window_active = window;
     6.9          return window;
    6.10      } else {
    6.11          asc_dprintf("Creating GL context failed for window %u", window->id);
    6.12 @@ -102,8 +102,8 @@
    6.13      if (window->id == 0) return;
    6.14  
    6.15      // this window cannot be active anymore
    6.16 -    if (asc_context.active_window == window) {
    6.17 -        asc_context.active_window = NULL;
    6.18 +    if (asc_window_active == window) {
    6.19 +        asc_window_active = NULL;
    6.20      }
    6.21  
    6.22      // destroy all scenes
    6.23 @@ -119,8 +119,8 @@
    6.24      }
    6.25  
    6.26      // if another window was active, make the other context current again
    6.27 -    if (asc_context.active_window != NULL) {
    6.28 -        asc_gl_context_activate(&asc_context.active_window->glctx);
    6.29 +    if (asc_window_active != NULL) {
    6.30 +        asc_gl_context_activate(&asc_window_active->glctx);
    6.31      }
    6.32  
    6.33      // clean the data
    6.34 @@ -129,7 +129,7 @@
    6.35  }
    6.36  
    6.37  void asc_window_sync(AscWindow* window) {
    6.38 -    AscWindow *active_window = asc_context.active_window;
    6.39 +    AscWindow *active_window = asc_window_active;
    6.40      if (window != active_window) {
    6.41          asc_window_activate(window);
    6.42      }
    6.43 @@ -159,5 +159,5 @@
    6.44  
    6.45  void asc_window_activate(AscWindow *window) {
    6.46      asc_gl_context_activate(&window->glctx);
    6.47 -    asc_context.active_window = (AscWindow *)window;
    6.48 +    asc_window_active = (AscWindow *)window;
    6.49  }

mercurial