src/window.c

changeset 99
ac143db979dc
parent 96
9e25f080a33e
equal deleted inserted replaced
98:83bec26453a8 99:ac143db979dc
75 ); 75 );
76 window->resized = true; // count initial sizing as resize 76 window->resized = true; // count initial sizing as resize
77 77
78 if (asc_gl_context_initialize(&window->glctx, window->window, &settings->glsettings)) { 78 if (asc_gl_context_initialize(&window->glctx, window->window, &settings->glsettings)) {
79 asc_scene_init(&window->ui); 79 asc_scene_init(&window->ui);
80 asc_camera_ortho(&window->ui.camera, (asc_recti){
81 0, 0, window->dimensions.width, window->dimensions.height
82 });
80 asc_dprintf("Window %u initialized at index %u", window->id, index); 83 asc_dprintf("Window %u initialized at index %u", window->id, index);
81 asc_context.active_window = index; 84 asc_context.active_window = index;
82 } else { 85 } else {
83 asc_error("Creating GL context failed for window %u at index %u", window->id, index); 86 asc_error("Creating GL context failed for window %u at index %u", window->id, index);
84 // cleanup on error 87 // cleanup on error
147 int window_height = window->dimensions.height; 150 int window_height = window->dimensions.height;
148 glViewport(0, 0, window_width, window_height); 151 glViewport(0, 0, window_width, window_height);
149 glClear(GL_COLOR_BUFFER_BIT); 152 glClear(GL_COLOR_BUFFER_BIT);
150 153
151 // Draw all scenes 154 // Draw all scenes
152 asc_recti viewport = {0, 0, window_width, window_height};
153 for (unsigned int i = 0; i < ASC_MAX_SCENES; i++) { 155 for (unsigned int i = 0; i < ASC_MAX_SCENES; i++) {
154 asc_scene_draw(&window->scenes[i], viewport); 156 asc_scene_draw(&window->scenes[i]);
155 } 157 }
156 asc_camera_ortho(&window->ui.camera, viewport); 158 asc_camera_ortho_update_size(&window->ui.camera, (asc_vec2i){window_width, window_height});
157 asc_scene_draw(&window->ui, viewport); 159 asc_scene_draw(&window->ui);
158 160
159 // Swap Buffers 161 // Swap Buffers
160 SDL_GL_SwapWindow(window->window); 162 SDL_GL_SwapWindow(window->window);
161 163
162 // Clear Flags 164 // Clear Flags

mercurial