src/window.c

changeset 287
359eaf2a8bd2
parent 262
b47de42f4598
child 288
8796f03aac26
equal deleted inserted replaced
286:26a41832c81d 287:359eaf2a8bd2
65 window->ui_scale = 1.0f; 65 window->ui_scale = 1.0f;
66 66
67 if (asc_gl_context_initialize(&window->glctx, window->window, &settings)) { 67 if (asc_gl_context_initialize(&window->glctx, window->window, &settings)) {
68 char ui_scene_name[16]; 68 char ui_scene_name[16];
69 snprintf(ui_scene_name, sizeof(ui_scene_name), "Window %u UI", index); 69 snprintf(ui_scene_name, sizeof(ui_scene_name), "Window %u UI", index);
70 asc_scene_init(&window->ui, ui_scene_name, 70 asc_camera_init(&window->ui_camera, .type = ASC_CAMERA_ORTHO,
71 .type = ASC_CAMERA_ORTHO,
72 .ortho.rect = ASC_RECT(0, 0, window->dimensions.width, window->dimensions.height), 71 .ortho.rect = ASC_RECT(0, 0, window->dimensions.width, window->dimensions.height),
73 .projection_update_func = asc_camera_ortho_update_size 72 .projection_update_func = asc_camera_ortho_update_size);
74 ); 73 asc_scene_init(&window->ui, ui_scene_name, &window->ui_camera);
75 asc_dprintf("Window %u initialized at index %u", window->id, index); 74 asc_dprintf("Window %u initialized at index %u", window->id, index);
76 asc_context.active_window = index; 75 asc_context.active_window = index;
77 } else { 76 } else {
78 asc_error("Creating GL context failed for window %u at index %u", window->id, index); 77 asc_error("Creating GL context failed for window %u at index %u", window->id, index);
79 // cleanup on error 78 // cleanup on error
145 144
146 // Update the viewports when the window resized 145 // Update the viewports when the window resized
147 if (window->resized) { 146 if (window->resized) {
148 for (unsigned int i = 0; i < ASC_MAX_SCENES; i++) { 147 for (unsigned int i = 0; i < ASC_MAX_SCENES; i++) {
149 if (asc_scene_active(&window->scenes[i])) { 148 if (asc_scene_active(&window->scenes[i])) {
150 asc_camera_update_viewport(&window->scenes[i].camera, window->dimensions); 149 asc_camera_update_viewport(window->scenes[i].camera, window->dimensions);
151 } 150 }
152 } 151 }
153 asc_camera_update_viewport(&window->ui.camera, window->dimensions); 152 asc_camera_update_viewport(window->ui.camera, window->dimensions);
154 } 153 }
155 154
156 // Execute all behaviors 155 // Execute all behaviors
157 // TODO: this can eventually be parallelized 156 // TODO: this can eventually be parallelized
158 for (unsigned int i = 0; i < ASC_MAX_SCENES; i++) { 157 for (unsigned int i = 0; i < ASC_MAX_SCENES; i++) {

mercurial