Browse code

Used GetRendererOutputSize to get screenshot size

Andrew Alderwick authored on 11/06/2021 08:56:14
Showing 1 changed files
... ...
@@ -88,7 +88,9 @@ void
88 88
 save_screenshot(void)
89 89
 {
90 90
 	const Uint32 format = SDL_PIXELFORMAT_ARGB8888;
91
-	SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormat(0, (ppu.width + PAD * 2) * zoom, (ppu.height + PAD * 2) * zoom, 32, format);
91
+	int w, h;
92
+	SDL_GetRendererOutputSize(gRenderer, &w, &h);
93
+	SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 32, format);
92 94
 	SDL_LockSurface(surface);
93 95
 	SDL_RenderReadPixels(gRenderer, NULL, format, surface->pixels, surface->pitch);
94 96
 	SDL_UnlockSurface(surface);