| 124 | } |
| 125 | |
| 126 | static void saveScreenshot(SDL_Renderer* renderer, const char* path) |
| 127 | { |
| 128 | SDL_Surface* surface = SDL_RenderReadPixels(renderer, nullptr); |
| 129 | if (!surface) |
| 130 | return; |
| 131 | SDL_Surface* rgb = SDL_ConvertSurface(surface, SDL_PIXELFORMAT_RGB24); |
| 132 | SDL_SaveBMP(rgb ? rgb : surface, path); |
| 133 | if (rgb) |
| 134 | SDL_DestroySurface(rgb); |
| 135 | SDL_DestroySurface(surface); |
| 136 | fprintf(stdout, "Screenshot saved: %s\n", path); |
| 137 | } |
| 138 | |
| 139 | int main(int argc, char* argv[]) |
| 140 | { |