minor improvements

Thu, 21 Mar 2024 20:34:33 +0100

author
Mike Becker <universe@uap-core.de>
date
Thu, 21 Mar 2024 20:34:33 +0100
changeset 39
7cf310cc47cb
parent 38
6e5629ea4c5c
child 40
6c438be1a1fd

minor improvements

src/ascension/ascension.h file | annotate | diff | comparison | revisions
src/ascension/scene.h file | annotate | diff | comparison | revisions
src/scene.c file | annotate | diff | comparison | revisions
src/window.c file | annotate | diff | comparison | revisions
     1.1 --- a/src/ascension/ascension.h	Thu Mar 21 20:24:31 2024 +0100
     1.2 +++ b/src/ascension/ascension.h	Thu Mar 21 20:34:33 2024 +0100
     1.3 @@ -34,5 +34,9 @@
     1.4  #include "text.h"
     1.5  #include "scene.h"
     1.6  
     1.7 +// some auto-casting magic
     1.8 +#define asc_node_update_transform(n) \
     1.9 +    asc_node_update_transform(((AscSceneNode*)n))
    1.10 +
    1.11  #endif /* ASCENSION_H */
    1.12  
     2.1 --- a/src/ascension/scene.h	Thu Mar 21 20:24:31 2024 +0100
     2.2 +++ b/src/ascension/scene.h	Thu Mar 21 20:34:33 2024 +0100
     2.3 @@ -59,7 +59,6 @@
     2.4      AscSceneNode *next;
     2.5      AscSceneNode *children;
     2.6      AscBehaviorNode *behaviors;
     2.7 -    void *data;
     2.8      asc_scene_free_func free_func;
     2.9      asc_scene_update_func update_func;
    2.10      asc_scene_update_func transform_update_func;
    2.11 @@ -68,7 +67,7 @@
    2.12      asc_transform local_transform;
    2.13      asc_transform final_transform;
    2.14      enum AscRenderGroup render_group;
    2.15 -    bool need_full_update;
    2.16 +    bool need_graphics_update;
    2.17      bool need_transform_update;
    2.18  };
    2.19  
    2.20 @@ -77,9 +76,6 @@
    2.21   */
    2.22  #define extend_asc_scene_node AscSceneNode base
    2.23  
    2.24 -#define asc_node_update(node) \
    2.25 -    ((AscSceneNode*)node)->need_full_update = true
    2.26 -
    2.27  struct asc_render_group_entry {
    2.28      asc_scene_draw_func draw;
    2.29      AscSceneNode const *node;
    2.30 @@ -142,6 +138,9 @@
    2.31  __attribute__((__nonnull__))
    2.32  void asc_scene_remove_behavior(AscBehaviorNode *node);
    2.33  
    2.34 +#define asc_node_update(node) \
    2.35 +    ((AscSceneNode*)node)->need_graphics_update = true
    2.36 +
    2.37  __attribute__((__nonnull__))
    2.38  void asc_node_update_transform(AscSceneNode *node);
    2.39  
     3.1 --- a/src/scene.c	Thu Mar 21 20:24:31 2024 +0100
     3.2 +++ b/src/scene.c	Thu Mar 21 20:34:33 2024 +0100
     3.3 @@ -102,9 +102,9 @@
     3.4          }
     3.5  
     3.6          // check if geometry needs update
     3.7 -        if (node->need_full_update) {
     3.8 +        if (node->need_graphics_update) {
     3.9              assert(node->update_func != NULL);
    3.10 -            node->need_full_update = false;
    3.11 +            node->need_graphics_update = false;
    3.12              node->update_func(node);
    3.13          }
    3.14          if (node->need_transform_update) {
    3.15 @@ -150,10 +150,16 @@
    3.16          camera->update(camera);
    3.17  
    3.18          // for the NONE group, the draw func is expected to do everything
    3.19 +        glEnable(GL_DEPTH_TEST);
    3.20 +        glDisable(GL_BLEND);
    3.21          asc_scene_draw_render_group(scene->rg_none);
    3.22  
    3.23          // draw the FONTS group
    3.24 +        glDisable(GL_DEPTH_TEST);
    3.25 +        glEnable(GL_BLEND);
    3.26 +        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    3.27          // TODO: see if we can really always ignore the view matrix
    3.28 +        // TODO: compute render order for alpha blending to work correctly
    3.29          glUseProgram(ASC_SHADER_FONT.base.id);
    3.30          glUniformMatrix4fv(ASC_SHADER_FONT.base.projection, 1,
    3.31                             GL_FALSE, camera->projection);
     4.1 --- a/src/window.c	Thu Mar 21 20:24:31 2024 +0100
     4.2 +++ b/src/window.c	Thu Mar 21 20:34:33 2024 +0100
     4.3 @@ -116,9 +116,6 @@
     4.4          GLenum err = glewInit();
     4.5          if (err == GLEW_OK) {
     4.6              SDL_GL_SetSwapInterval(settings->vsync);
     4.7 -            glEnable(GL_DEPTH_TEST);
     4.8 -            glEnable(GL_BLEND);
     4.9 -            glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    4.10              glEnable(GL_DEBUG_OUTPUT);
    4.11              glDebugMessageCallback(asc_gl_debug_callback, NULL);
    4.12  

mercurial