Skip to content

Commit

Permalink
Use SDL_CreateWindowAndRenderer()
Browse files Browse the repository at this point in the history
This avoids window flash (recreation) if we create an OpenGL renderer on X11, and is the recommended use pattern.
  • Loading branch information
slouken committed Dec 30, 2024
1 parent 6a88efd commit e65f96e
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,8 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
return SDL_APP_FAILURE;
}

window = SDL_CreateWindow("Hello SDL", 640, 480, 0);
if (!window) {
SDL_Log("SDL_CreateWindow() failed: %s", SDL_GetError());
return SDL_APP_FAILURE;
}

renderer = SDL_CreateRenderer(window, NULL);
if (!renderer) {
SDL_Log("SDL_CreateRenderer() failed: %s", SDL_GetError());
if (!SDL_CreateWindowAndRenderer("Hello SDL", 640, 480, 0, &window, &renderer)) {
SDL_Log("SDL_CreateWindowAndRenderer() failed: %s", SDL_GetError());
return SDL_APP_FAILURE;
}

Expand Down

0 comments on commit e65f96e

Please sign in to comment.