- fixed crash after saving a screenshot

https://forum.zdoom.org/viewtopic.php?t=60616
This commit is contained in:
alexey.lysiuk 2018-05-19 13:19:24 +03:00
parent 5ec47d8b4f
commit ace5ee3c41
2 changed files with 3 additions and 4 deletions

View File

@ -470,16 +470,16 @@ void OpenGLFrameBuffer::GetScreenshotBuffer(const uint8_t *&buffer, int &pitch,
int sx = u * viewport.width; int sx = u * viewport.width;
int sy = v * viewport.height; int sy = v * viewport.height;
int sindex = (sx + sy * viewport.width) * 3; 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] = pixels[sindex];
ScreenshotBuffer[dindex + 1] = pixels[sindex + 1]; ScreenshotBuffer[dindex + 1] = pixels[sindex + 1];
ScreenshotBuffer[dindex + 2] = pixels[sindex + 2]; ScreenshotBuffer[dindex + 2] = pixels[sindex + 2];
} }
} }
pitch = -w*3; pitch = w * 3;
color_type = SS_RGB; 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 // Screenshot should not use gamma correction if it was already applied to rendered image
EXTERN_CVAR(Bool, fullscreen); EXTERN_CVAR(Bool, fullscreen);

View File

@ -64,7 +64,6 @@ public:
bool HWGammaActive = false; // Are we using hardware or software gamma? bool HWGammaActive = false; // Are we using hardware or software gamma?
std::shared_ptr<FGLDebug> mDebug; // Debug API std::shared_ptr<FGLDebug> mDebug; // Debug API
private: 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; int camtexcount = 0;
class Wiper class Wiper