Used GetRendererOutputSize to get screenshot size

This commit is contained in:
Andrew Alderwick 2021-06-11 09:56:14 +01:00
parent a11cbb458f
commit 52e0f9b29e
1 changed files with 3 additions and 1 deletions

View File

@ -88,7 +88,9 @@ void
save_screenshot(void)
{
const Uint32 format = SDL_PIXELFORMAT_ARGB8888;
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormat(0, (ppu.width + PAD * 2) * zoom, (ppu.height + PAD * 2) * zoom, 32, format);
int w, h;
SDL_GetRendererOutputSize(gRenderer, &w, &h);
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 32, format);
SDL_LockSurface(surface);
SDL_RenderReadPixels(gRenderer, NULL, format, surface->pixels, surface->pitch);
SDL_UnlockSurface(surface);