Adjust GL1 and GL3 ReadFrame to take pixel ratio into account.
Currently, on HiDPI screens the Export Image command would return a cropped screenshot.pull/420/head
parent
11c5cdc7b0
commit
f43954cc29
|
@ -814,9 +814,12 @@ void OpenGl1Renderer::FlushFrame() {
|
|||
}
|
||||
|
||||
std::shared_ptr<Pixmap> OpenGl1Renderer::ReadFrame() {
|
||||
int width = camera.width * camera.pixelRatio;
|
||||
int height = camera.height * camera.pixelRatio;
|
||||
std::shared_ptr<Pixmap> 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -679,10 +679,11 @@ void OpenGl3Renderer::Clear() {
|
|||
}
|
||||
|
||||
std::shared_ptr<Pixmap> OpenGl3Renderer::ReadFrame() {
|
||||
int width = camera.width * camera.pixelRatio;
|
||||
int height = camera.height * camera.pixelRatio;
|
||||
std::shared_ptr<Pixmap> 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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue