src/scene.c

changeset 100
5231da78831e
parent 99
ac143db979dc
equal deleted inserted replaced
99:ac143db979dc 100:5231da78831e
38 38
39 #include <GL/glew.h> 39 #include <GL/glew.h>
40 40
41 #include <assert.h> 41 #include <assert.h>
42 42
43 void asc_scene_init(AscScene *scene) { 43 void asc_scene_init(AscScene *scene, AscCameraParams camera_params) {
44 if (scene->root != NULL) { 44 if (scene->root != NULL) {
45 asc_wprintf("Scene %"PRIxPTR" is already initialized - initialization skipped.", (uintptr_t) scene); 45 asc_wprintf("Scene %"PRIxPTR" is already initialized - initialization skipped.", (uintptr_t) scene);
46 return; 46 return;
47 } 47 }
48 if (camera_params.type == ASC_CAMERA_ORTHO) {
49 asc_camera_ortho(&scene->camera, camera_params.ortho.rect);
50 } else if (camera_params.type == ASC_CAMERA_PERSPECTIVE) {
51 // TODO: implement
52 asc_wprintf("Camera type PERSPECTIVE is not yet implemented.");
53 } else {
54 // at least zero all the bytes (law of the least surprise)
55 memset(&scene->camera, 0, sizeof(AscCamera));
56 }
57 scene->camera.viewport_update_func = camera_params.viewport_update_func;
58 scene->root = asc_scene_node_empty();
59
48 asc_dprintf("Initialized scene %"PRIxPTR, (uintptr_t) scene); 60 asc_dprintf("Initialized scene %"PRIxPTR, (uintptr_t) scene);
49 // TODO: how should we initialize the camera?
50 scene->root = asc_scene_node_empty();
51 } 61 }
52 62
53 void asc_scene_destroy(AscScene *scene) { 63 void asc_scene_destroy(AscScene *scene) {
54 if (scene->root == NULL) return; 64 if (scene->root == NULL) return;
55 65

mercurial