Thu, 21 Mar 2024 20:34:33 +0100
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 |
--- a/src/ascension/ascension.h Thu Mar 21 20:24:31 2024 +0100 +++ b/src/ascension/ascension.h Thu Mar 21 20:34:33 2024 +0100 @@ -34,5 +34,9 @@ #include "text.h" #include "scene.h" +// some auto-casting magic +#define asc_node_update_transform(n) \ + asc_node_update_transform(((AscSceneNode*)n)) + #endif /* ASCENSION_H */
--- a/src/ascension/scene.h Thu Mar 21 20:24:31 2024 +0100 +++ b/src/ascension/scene.h Thu Mar 21 20:34:33 2024 +0100 @@ -59,7 +59,6 @@ AscSceneNode *next; AscSceneNode *children; AscBehaviorNode *behaviors; - void *data; asc_scene_free_func free_func; asc_scene_update_func update_func; asc_scene_update_func transform_update_func; @@ -68,7 +67,7 @@ asc_transform local_transform; asc_transform final_transform; enum AscRenderGroup render_group; - bool need_full_update; + bool need_graphics_update; bool need_transform_update; }; @@ -77,9 +76,6 @@ */ #define extend_asc_scene_node AscSceneNode base -#define asc_node_update(node) \ - ((AscSceneNode*)node)->need_full_update = true - struct asc_render_group_entry { asc_scene_draw_func draw; AscSceneNode const *node; @@ -142,6 +138,9 @@ __attribute__((__nonnull__)) void asc_scene_remove_behavior(AscBehaviorNode *node); +#define asc_node_update(node) \ + ((AscSceneNode*)node)->need_graphics_update = true + __attribute__((__nonnull__)) void asc_node_update_transform(AscSceneNode *node);
--- a/src/scene.c Thu Mar 21 20:24:31 2024 +0100 +++ b/src/scene.c Thu Mar 21 20:34:33 2024 +0100 @@ -102,9 +102,9 @@ } // check if geometry needs update - if (node->need_full_update) { + if (node->need_graphics_update) { assert(node->update_func != NULL); - node->need_full_update = false; + node->need_graphics_update = false; node->update_func(node); } if (node->need_transform_update) { @@ -150,10 +150,16 @@ camera->update(camera); // for the NONE group, the draw func is expected to do everything + glEnable(GL_DEPTH_TEST); + glDisable(GL_BLEND); asc_scene_draw_render_group(scene->rg_none); // draw the FONTS group + glDisable(GL_DEPTH_TEST); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // TODO: see if we can really always ignore the view matrix + // TODO: compute render order for alpha blending to work correctly glUseProgram(ASC_SHADER_FONT.base.id); glUniformMatrix4fv(ASC_SHADER_FONT.base.projection, 1, GL_FALSE, camera->projection);
--- a/src/window.c Thu Mar 21 20:24:31 2024 +0100 +++ b/src/window.c Thu Mar 21 20:34:33 2024 +0100 @@ -116,9 +116,6 @@ GLenum err = glewInit(); if (err == GLEW_OK) { SDL_GL_SetSwapInterval(settings->vsync); - glEnable(GL_DEPTH_TEST); - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_DEBUG_OUTPUT); glDebugMessageCallback(asc_gl_debug_callback, NULL);