src/scene.c

changeset 150
3045f61bc4eb
parent 148
9f030f402699
--- a/src/scene.c	Sat Jun 14 11:40:40 2025 +0200
+++ b/src/scene.c	Sat Jun 14 12:38:37 2025 +0200
@@ -30,7 +30,6 @@
 #include "ascension/scene.h"
 #include "ascension/behavior.h"
 #include "ascension/shader.h"
-#include "ascension/sprite.h"
 
 #include <cx/tree.h>
 #include <cx/array_list.h>
@@ -76,7 +75,7 @@
     }
 }
 
-static void asc_scene_draw_sprites(
+static void asc_scene_draw2d(
         const AscScene *scene,
         const CxList *opaque,
         const CxList *blend
@@ -85,25 +84,25 @@
     glClear(GL_DEPTH_BUFFER_BIT);
     const AscCamera *camera = asc_scene_camera(scene);
 
-    // render opaque sprites from front to back
+    // render opaque nodes from front to back
     CxIterator iter_opaque = cxListBackwardsIterator(opaque);
 
-    // render sprites with alpha value from back to front
+    // render nodes with alpha blending from back to front
     CxIterator iter_blend = cxListIterator(blend);
 
     // TODO: implement interleaving by depth
     // TODO: implement sorting by shader ID to reduce shader switches
     if (cxIteratorValid(iter_opaque)) {
         glDisable(GL_BLEND);
-        cx_foreach(const AscSprite*, node, iter_opaque) {
-            asc_sprite_draw(camera, node);
+        cx_foreach(const AscSceneNode*, node, iter_opaque) {
+            node->draw_func(camera, node);
         }
     }
     if (cxIteratorValid(iter_blend)) {
         glEnable(GL_BLEND);
         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-        cx_foreach(const AscSprite*, node, iter_blend) {
-            asc_sprite_draw(camera, node);
+        cx_foreach(const AscSceneNode*, node, iter_blend) {
+            node->draw_func(camera, node);
         }
     }
 }
@@ -210,13 +209,9 @@
     asc_shader_use(NULL, NULL);
 
     // 2D Elements
-    // ===========
-
-    // Sprites
-    // -------
-    asc_scene_draw_sprites(scene,
-        render_group[ASC_RENDER_GROUP_SPRITE_OPAQUE],
-        render_group[ASC_RENDER_GROUP_SPRITE_BLEND]
+    asc_scene_draw2d(scene,
+        render_group[ASC_RENDER_GROUP_2D_OPAQUE],
+        render_group[ASC_RENDER_GROUP_2D_BLEND]
     );
 }
 

mercurial