diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-09-28 14:21:37 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-09-28 14:21:37 +0300 |
commit | e3495ede6128250b7b3f4326a784be2fa6a10b22 (patch) | |
tree | a91072ab07dafa2a49afa37e57f43871875c4496 | |
parent | 460f125e6a1278136768e18cf654c141b4274d71 (diff) |
Window: Automatic software rendering fallback
-rw-r--r-- | src/ui/window.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/ui/window.c b/src/ui/window.c index d66015a8..686a6dd6 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -380,12 +380,6 @@ void create_Window_(iWindow *d, iRect rect, uint32_t flags) { | |||
380 | } | 380 | } |
381 | #endif | 381 | #endif |
382 | } | 382 | } |
383 | #if 0 | ||
384 | if (SDL_CreateWindowAndRenderer( | ||
385 | width_Rect(rect), height_Rect(rect), flags, &d->win, &d->render)) { | ||
386 | return iFalse; | ||
387 | } | ||
388 | #endif | ||
389 | const iBool setPos = left_Rect(rect) >= 0 || top_Rect(rect) >= 0; | 383 | const iBool setPos = left_Rect(rect) >= 0 || top_Rect(rect) >= 0; |
390 | d->win = SDL_CreateWindow("", | 384 | d->win = SDL_CreateWindow("", |
391 | setPos ? left_Rect(rect) : SDL_WINDOWPOS_CENTERED, | 385 | setPos ? left_Rect(rect) : SDL_WINDOWPOS_CENTERED, |
@@ -394,8 +388,20 @@ void create_Window_(iWindow *d, iRect rect, uint32_t flags) { | |||
394 | height_Rect(rect), | 388 | height_Rect(rect), |
395 | flags); | 389 | flags); |
396 | if (!d->win) { | 390 | if (!d->win) { |
397 | fprintf(stderr, "[window] failed to create window: %s\n", SDL_GetError()); | 391 | if (flags & SDL_WINDOW_OPENGL) { |
398 | exit(-3); | 392 | /* Try without OpenGL support, then. */ |
393 | setForceSoftwareRender_App(iTrue); | ||
394 | d->win = SDL_CreateWindow("", | ||
395 | setPos ? left_Rect(rect) : SDL_WINDOWPOS_CENTERED, | ||
396 | setPos ? top_Rect(rect) : SDL_WINDOWPOS_CENTERED, | ||
397 | width_Rect(rect), | ||
398 | height_Rect(rect), | ||
399 | flags & ~SDL_WINDOW_OPENGL); | ||
400 | } | ||
401 | if (!d->win) { | ||
402 | fprintf(stderr, "[window] failed to create window: %s\n", SDL_GetError()); | ||
403 | exit(-3); | ||
404 | } | ||
399 | } | 405 | } |
400 | if (forceSoftwareRender_App()) { | 406 | if (forceSoftwareRender_App()) { |
401 | SDL_SetHint(SDL_HINT_RENDER_DRIVER, "software"); | 407 | SDL_SetHint(SDL_HINT_RENDER_DRIVER, "software"); |