118 } |
118 } |
119 |
119 |
120 void asc_scene_draw(AscScene *scene) { |
120 void asc_scene_draw(AscScene *scene) { |
121 if (scene->root == NULL) return; |
121 if (scene->root == NULL) return; |
122 |
122 |
123 // if the window resized, we must update the viewport |
|
124 if (asc_active_window->resized) { |
|
125 asc_vec2u window_size = asc_active_window->dimensions; |
|
126 if (scene->camera.viewport_update_func == NULL) { |
|
127 // this assumes the viewport was initialized with zeros! |
|
128 scene->camera.viewport.size = window_size; |
|
129 } else { |
|
130 scene->camera.viewport = scene->camera.viewport_update_func(window_size); |
|
131 } |
|
132 if (scene->camera.projection_update_func != NULL) { |
|
133 scene->camera.projection_update_func(&scene->camera, window_size); |
|
134 } |
|
135 } |
|
136 |
|
137 // when the viewport is zero, exit immediately |
123 // when the viewport is zero, exit immediately |
138 if (scene->camera.viewport.size.width == 0 || scene->camera.viewport.size.height == 0) { |
124 if (scene->camera.viewport.size.width == 0 || scene->camera.viewport.size.height == 0) { |
139 return; |
125 return; |
140 } |
126 } |
141 |
127 |