src/scene.c

changeset 100
5231da78831e
parent 99
ac143db979dc
--- a/src/scene.c	Sun Apr 27 15:17:12 2025 +0200
+++ b/src/scene.c	Mon Apr 28 21:13:01 2025 +0200
@@ -40,14 +40,24 @@
 
 #include <assert.h>
 
-void asc_scene_init(AscScene *scene) {
+void asc_scene_init(AscScene *scene, AscCameraParams camera_params) {
     if (scene->root != NULL) {
         asc_wprintf("Scene %"PRIxPTR" is already initialized - initialization skipped.", (uintptr_t) scene);
         return;
     }
+    if (camera_params.type == ASC_CAMERA_ORTHO) {
+        asc_camera_ortho(&scene->camera, camera_params.ortho.rect);
+    } else if (camera_params.type == ASC_CAMERA_PERSPECTIVE) {
+        // TODO: implement
+        asc_wprintf("Camera type PERSPECTIVE is not yet implemented.");
+    } else {
+        // at least zero all the bytes (law of the least surprise)
+        memset(&scene->camera, 0, sizeof(AscCamera));
+    }
+    scene->camera.viewport_update_func = camera_params.viewport_update_func;
+    scene->root = asc_scene_node_empty();
+
     asc_dprintf("Initialized scene %"PRIxPTR, (uintptr_t) scene);
-    // TODO: how should we initialize the camera?
-    scene->root = asc_scene_node_empty();
 }
 
 void asc_scene_destroy(AscScene *scene) {

mercurial