| 1517 | } |
| 1518 | |
| 1519 | static void |
| 1520 | SDLTest_ScreenShot(SDL_Renderer *renderer) |
| 1521 | { |
| 1522 | SDL_Rect viewport; |
| 1523 | SDL_Surface *surface; |
| 1524 | |
| 1525 | if (!renderer) { |
| 1526 | return; |
| 1527 | } |
| 1528 | |
| 1529 | SDL_RenderGetViewport(renderer, &viewport); |
| 1530 | surface = SDL_CreateRGBSurface(0, viewport.w, viewport.h, 24, |
| 1531 | #if SDL_BYTEORDER == SDL_LIL_ENDIAN |
| 1532 | 0x00FF0000, 0x0000FF00, 0x000000FF, |
| 1533 | #else |
| 1534 | 0x000000FF, 0x0000FF00, 0x00FF0000, |
| 1535 | #endif |
| 1536 | 0x00000000); |
| 1537 | if (!surface) { |
| 1538 | SDL_Log("Couldn't create surface: %s\n", SDL_GetError()); |
| 1539 | return; |
| 1540 | } |
| 1541 | |
| 1542 | if (SDL_RenderReadPixels(renderer, NULL, surface->format->format, |
| 1543 | surface->pixels, surface->pitch) < 0) { |
| 1544 | SDL_Log("Couldn't read screen: %s\n", SDL_GetError()); |
| 1545 | SDL_free(surface); |
| 1546 | return; |
| 1547 | } |
| 1548 | |
| 1549 | if (SDL_SaveBMP(surface, "screenshot.bmp") < 0) { |
| 1550 | SDL_Log("Couldn't save screenshot.bmp: %s\n", SDL_GetError()); |
| 1551 | SDL_free(surface); |
| 1552 | return; |
| 1553 | } |
| 1554 | } |
| 1555 | |
| 1556 | static void |
| 1557 | FullscreenTo(int index, int windowId) |
no test coverage detected