mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-29 02:34:23 +00:00
examples: Use SDL_Log() instead of message boxes for errors.
Fixes #11094.
This commit is contained in:
@@ -27,28 +27,28 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
|
||||
int devcount = 0;
|
||||
|
||||
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_CAMERA)) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't initialize SDL!", SDL_GetError(), NULL);
|
||||
SDL_Log("Couldn't initialize SDL: %s", SDL_GetError());
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
||||
if (!SDL_CreateWindowAndRenderer("examples/camera/read-and-draw", 640, 480, 0, &window, &renderer)) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't create window/renderer!", SDL_GetError(), NULL);
|
||||
SDL_Log("Couldn't create window/renderer: %s", SDL_GetError());
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
||||
devices = SDL_GetCameras(&devcount);
|
||||
if (devices == NULL) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't enumerate camera devices!", SDL_GetError(), window);
|
||||
SDL_Log("Couldn't enumerate camera devices: %s", SDL_GetError());
|
||||
return SDL_APP_FAILURE;
|
||||
} else if (devcount == 0) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't find any camera devices!", "Please connect a camera and try again.", window);
|
||||
SDL_Log("Couldn't find any camera devices! Please connect a camera and try again.");
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
||||
camera = SDL_OpenCamera(devices[0], NULL); // just take the first thing we see in any format it wants.
|
||||
SDL_free(devices);
|
||||
if (camera == NULL) {
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Couldn't open camera!", SDL_GetError(), window);
|
||||
SDL_Log("Couldn't open camera: %s", SDL_GetError());
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,6 @@ SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
|
||||
SDL_Log("Camera use approved by user!");
|
||||
} else if (event->type == SDL_EVENT_CAMERA_DEVICE_DENIED) {
|
||||
SDL_Log("Camera use denied by user!");
|
||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Camera permission denied!", "User denied access to the camera!", window);
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
return SDL_APP_CONTINUE; /* carry on with the program! */
|
||||
|
||||
Reference in New Issue
Block a user