diff --git a/src/render/rendergl1.cpp b/src/render/rendergl1.cpp index de486444..a5552281 100644 --- a/src/render/rendergl1.cpp +++ b/src/render/rendergl1.cpp @@ -814,9 +814,12 @@ void OpenGl1Renderer::FlushFrame() { } std::shared_ptr OpenGl1Renderer::ReadFrame() { + int width = camera.width * camera.pixelRatio; + int height = camera.height * camera.pixelRatio; std::shared_ptr pixmap = - Pixmap::Create(Pixmap::Format::RGB, (size_t)camera.width, (size_t)camera.height); - glReadPixels(0, 0, camera.width, camera.height, GL_RGB, GL_UNSIGNED_BYTE, &pixmap->data[0]); + Pixmap::Create(Pixmap::Format::RGB, (size_t)width, (size_t)height); + glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, &pixmap->data[0]); + ssassert(glGetError() == GL_NO_ERROR, "Unexpected glReadPixels error"); return pixmap; } diff --git a/src/render/rendergl3.cpp b/src/render/rendergl3.cpp index ce201aca..3ccf6236 100644 --- a/src/render/rendergl3.cpp +++ b/src/render/rendergl3.cpp @@ -679,10 +679,11 @@ void OpenGl3Renderer::Clear() { } std::shared_ptr OpenGl3Renderer::ReadFrame() { + int width = camera.width * camera.pixelRatio; + int height = camera.height * camera.pixelRatio; std::shared_ptr pixmap = - Pixmap::Create(Pixmap::Format::RGBA, (size_t)camera.width, (size_t)camera.height); - glReadPixels(0, 0, (int)camera.width, (int)camera.height, - GL_RGBA, GL_UNSIGNED_BYTE, &pixmap->data[0]); + Pixmap::Create(Pixmap::Format::RGBA, (size_t)width, (size_t)height); + glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, &pixmap->data[0]); ssassert(glGetError() == GL_NO_ERROR, "Unexpected glReadPixels error"); return pixmap; }