Remove SDL_VideoInit / Quit. Prefer SDL_SubSytemInit / Quit (#6913)

This commit is contained in:
Sylvain Becker
2022-12-27 14:42:48 +01:00
committed by GitHub
parent 713ba2e31a
commit aa0053141b
14 changed files with 86 additions and 73 deletions

View File

@@ -44,7 +44,7 @@ static SDL_Rect *positions, *velocities;
static void
quit(int rc)
{
SDL_VideoQuit();
SDL_Quit();
if (native_window != NULL && factory != NULL) {
factory->DestroyNativeWindow(native_window);
}
@@ -103,7 +103,7 @@ int main(int argc, char *argv[])
/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
if (SDL_VideoInit(NULL) < 0) {
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL video: %s\n",
SDL_GetError());
exit(1);

View File

@@ -102,7 +102,8 @@ int main(int argc, char *argv[])
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Force the offscreen renderer, if it cannot be created then fail out */
if (SDL_VideoInit("offscreen") < 0) {
SDL_SetHint("SDL_VIDEO_DRIVER", "offscreen");
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
SDL_Log("Couldn't initialize the offscreen video driver: %s\n",
SDL_GetError());
return SDL_FALSE;

View File

@@ -63,7 +63,7 @@ int main(int argc, char **argv)
exit(-1);
}
if (SDL_VideoInit(NULL) == -1) {
if (SDL_Init(SDL_INIT_VIDEO) == -1) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not initialize SDL video.");
exit(-2);
}
@@ -85,7 +85,7 @@ int main(int argc, char **argv)
SDL_FreeSurface(pictures[j].surface);
}
SDL_free(pictures);
SDL_VideoQuit();
SDL_Quit();
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not load surface from named bitmap file: %s", argv[i + 1]);
exit(-3);
}
@@ -110,7 +110,7 @@ int main(int argc, char **argv)
SDL_FreeSurface(pictures[i].surface);
}
SDL_free(pictures);
SDL_VideoQuit();
SDL_Quit();
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create shaped window for SDL_Shape.");
exit(-4);
}
@@ -121,7 +121,7 @@ int main(int argc, char **argv)
SDL_FreeSurface(pictures[i].surface);
}
SDL_free(pictures);
SDL_VideoQuit();
SDL_Quit();
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create rendering context for SDL_Shape window.");
exit(-5);
}
@@ -143,7 +143,7 @@ int main(int argc, char **argv)
SDL_free(pictures);
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_VideoQuit();
SDL_Quit();
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create texture for SDL_shape.");
exit(-6);
}
@@ -201,8 +201,8 @@ int main(int argc, char **argv)
SDL_FreeSurface(pictures[i].surface);
}
SDL_free(pictures);
/* Call SDL_VideoQuit() before quitting. */
SDL_VideoQuit();
/* Call SDL_Quit() before quitting. */
SDL_Quit();
return 0;
}