| 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) { |
| |
44 if (scene->root != NULL) { |
| |
45 asc_wprintf("Scene %"PRIxPTR" is already initialized - initialization skipped.", (uintptr_t) scene); |
| |
46 return; |
| |
47 } |
| 44 asc_dprintf("Initialized scene %"PRIxPTR, (uintptr_t) scene); |
48 asc_dprintf("Initialized scene %"PRIxPTR, (uintptr_t) scene); |
| 45 // TODO: how should we initialize the camera? |
49 // TODO: how should we initialize the camera? |
| 46 scene->root = asc_scene_node_empty(); |
50 scene->root = asc_scene_node_empty(); |
| 47 } |
51 } |
| 48 |
52 |
| 49 void asc_scene_destroy(AscScene *scene) { |
53 void asc_scene_destroy(AscScene *scene) { |
| |
54 if (scene->root == NULL) return; |
| |
55 |
| 50 asc_dprintf("Destroyed scene %"PRIxPTR, (uintptr_t) scene); |
56 asc_dprintf("Destroyed scene %"PRIxPTR, (uintptr_t) scene); |
| 51 asc_scene_node_free(scene->root); |
57 asc_scene_node_free(scene->root); |
| 52 } |
58 } |
| 53 |
59 |
| 54 void asc_scene_draw(AscScene *scene, asc_recti viewport) { |
60 void asc_scene_draw(AscScene *scene, asc_recti viewport) { |
| |
61 if (scene->root == NULL) return; |
| |
62 |
| 55 // create render groups |
63 // create render groups |
| 56 CxList *render_group[ASC_RENDER_GROUP_COUNT]; |
64 CxList *render_group[ASC_RENDER_GROUP_COUNT]; |
| 57 cx_for_n(i, ASC_RENDER_GROUP_COUNT) { |
65 cx_for_n(i, ASC_RENDER_GROUP_COUNT) { |
| 58 render_group[i] = cxArrayListCreateSimple(CX_STORE_POINTERS, 32); |
66 render_group[i] = cxArrayListCreateSimple(CX_STORE_POINTERS, 32); |
| 59 } |
67 } |