From ace5ee3c41dd609dc9a67e496ebb03cc918d2888 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 19 May 2018 13:19:24 +0300 Subject: [PATCH] - fixed crash after saving a screenshot https://forum.zdoom.org/viewtopic.php?t=60616 --- src/gl/system/gl_framebuffer.cpp | 6 +++--- src/gl/system/gl_framebuffer.h | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index d83581249..81cbd7eeb 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -470,16 +470,16 @@ void OpenGLFrameBuffer::GetScreenshotBuffer(const uint8_t *&buffer, int &pitch, int sx = u * viewport.width; int sy = v * viewport.height; int sindex = (sx + sy * viewport.width) * 3; - int dindex = (x + y * w) * 3; + int dindex = (x + (h - y - 1) * w) * 3; ScreenshotBuffer[dindex] = pixels[sindex]; ScreenshotBuffer[dindex + 1] = pixels[sindex + 1]; ScreenshotBuffer[dindex + 2] = pixels[sindex + 2]; } } - pitch = -w*3; + pitch = w * 3; color_type = SS_RGB; - buffer = ScreenshotBuffer + w * 3 * (h - 1); + buffer = ScreenshotBuffer; // Screenshot should not use gamma correction if it was already applied to rendered image EXTERN_CVAR(Bool, fullscreen); diff --git a/src/gl/system/gl_framebuffer.h b/src/gl/system/gl_framebuffer.h index a220b0a34..898820cc9 100644 --- a/src/gl/system/gl_framebuffer.h +++ b/src/gl/system/gl_framebuffer.h @@ -64,7 +64,6 @@ public: bool HWGammaActive = false; // Are we using hardware or software gamma? std::shared_ptr mDebug; // Debug API private: - uint8_t *ScreenshotBuffer; // What the name says. This must be maintained because the software renderer can return a locked canvas surface which the caller cannot release. int camtexcount = 0; class Wiper