| 144 } |
144 } |
| 145 AscWindow *window = &asc_context.windows[index]; |
145 AscWindow *window = &asc_context.windows[index]; |
| 146 // necessary safeguard |
146 // necessary safeguard |
| 147 if (window->id == 0) return; |
147 if (window->id == 0) return; |
| 148 |
148 |
| 149 // active the window that shall be synced temporarily |
149 // activate the window that shall be synced temporarily |
| 150 unsigned int active_index = asc_context.active_window; |
150 unsigned int active_index = asc_window_activate(index); |
| 151 if (index != active_index) { |
|
| 152 asc_window_activate(index); |
|
| 153 } |
|
| 154 |
151 |
| 155 // Clear the color buffer for the window frame |
152 // Clear the color buffer for the window frame |
| 156 glViewport(0, 0, |
153 glViewport(0, 0, |
| 157 (GLsizei) window->rect.size.width, |
154 (GLsizei) window->rect.size.width, |
| 158 (GLsizei) window->rect.size.height); |
155 (GLsizei) window->rect.size.height); |
| 194 |
191 |
| 195 // Clear Flags |
192 // Clear Flags |
| 196 window->resized = false; |
193 window->resized = false; |
| 197 window->moved = false; |
194 window->moved = false; |
| 198 |
195 |
| 199 if (index != active_index) { |
196 asc_window_activate(active_index); |
| 200 asc_window_activate(active_index); |
197 } |
| 201 } |
198 |
| 202 } |
199 unsigned int asc_window_activate(unsigned int index) { |
| 203 |
200 unsigned int active_index = asc_context.active_window; |
| 204 void asc_window_activate(unsigned int index) { |
201 if (active_index != index) { |
| 205 asc_context.active_window = index; |
202 asc_context.active_window = index; |
| 206 asc_gl_context_activate(&asc_active_window->glctx); |
203 asc_gl_context_activate(&asc_active_window->glctx); |
| |
204 return active_index; |
| |
205 } |
| |
206 return index; |
| 207 } |
207 } |
| 208 |
208 |
| 209 unsigned int asc_window_index(Uint32 id) { |
209 unsigned int asc_window_index(Uint32 id) { |
| 210 unsigned int i = 0; |
210 unsigned int i = 0; |
| 211 for (; i < ASC_MAX_WINDOWS ; i++) { |
211 for (; i < ASC_MAX_WINDOWS ; i++) { |
| 271 const AscWindow *window = asc_context.windows + index; |
271 const AscWindow *window = asc_context.windows + index; |
| 272 assert(window->sdl != NULL); |
272 assert(window->sdl != NULL); |
| 273 // TODO: check what needs to be changed when SDL_WINDOW_ALLOW_HIGHDPI is supported by the engine |
273 // TODO: check what needs to be changed when SDL_WINDOW_ALLOW_HIGHDPI is supported by the engine |
| 274 SDL_SetWindowSize(window->sdl, (int)size.width, (int)size.height); |
274 SDL_SetWindowSize(window->sdl, (int)size.width, (int)size.height); |
| 275 } |
275 } |
| |
276 |
| |
277 void asc_window_fullscreen(unsigned index, bool fullscreen) { |
| |
278 const AscWindow *window = asc_context.windows + index; |
| |
279 assert(window->sdl != NULL); |
| |
280 SDL_SetWindowFullscreen(window->sdl, fullscreen); |
| |
281 } |
| |
282 |
| |
283 void asc_window_vsync(unsigned index, bool vsync) { |
| |
284 unsigned int active_index = asc_window_activate(index); |
| |
285 SDL_GL_SetSwapInterval(vsync ? 1 : 0); |
| |
286 asc_window_activate(active_index); |
| |
287 } |