From 2bcdfdb23a0b23a64705bf11a7a88c93614d7585 Mon Sep 17 00:00:00 2001 From: Roza Date: Wed, 26 Feb 2020 17:34:54 -0500 Subject: [PATCH] Take aspect ratio into account when screenshotting --- src/graphics.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/graphics.cpp b/src/graphics.cpp index 6209a27c..4831ee1a 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -862,7 +862,8 @@ void Graphics::screenshot(const char *filename) { if (!img) throw new Exception(Exception::SDLError, "%s", SDL_GetError()); - glReadPixels(0, 0, w, h, GL_BGRA, GL_UNSIGNED_BYTE, img->pixels); + glReadPixels(p->scOffset.x, p->scOffset.y, w, h, GL_BGRA, GL_UNSIGNED_BYTE, + img->pixels); #else SDL_Surface *tmp, *img; tmp = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, 0, 0, 0, 0); @@ -875,7 +876,8 @@ void Graphics::screenshot(const char *filename) { throw Exception(Exception::SDLError, "%s", SDL_GetError()); } - glReadPixels(0, 0, w, h, GL_BGRA, GL_UNSIGNED_BYTE, tmp->pixels); + glReadPixels(p->scOffset.x, p->scOffset.y, w, h, GL_BGRA, GL_UNSIGNED_BYTE, + tmp->pixels); for (int i = 0; i < h; i++) { memcpy((char *)img->pixels + 4 * w * i,