Merge pull request #8162 from SamGondelman/snapshotFix

Snapshot takes picture of HMD window instead of preview
This commit is contained in:
Brad Hefta-Gaub 2016-07-05 09:25:59 -07:00 committed by GitHub
commit 372f8245e6

View file

@ -647,12 +647,13 @@ void OpenGLDisplayPlugin::withMainThreadContext(std::function<void()> f) const {
} }
QImage OpenGLDisplayPlugin::getScreenshot() const { QImage OpenGLDisplayPlugin::getScreenshot() const {
QImage result; using namespace oglplus;
QImage screenshot(_compositeFramebuffer->size.x, _compositeFramebuffer->size.y, QImage::Format_RGBA8888);
withMainThreadContext([&] { withMainThreadContext([&] {
static auto widget = _container->getPrimaryWidget(); Framebuffer::Bind(Framebuffer::Target::Read, _compositeFramebuffer->fbo);
result = widget->grabFrameBuffer(); Context::ReadPixels(0, 0, _compositeFramebuffer->size.x, _compositeFramebuffer->size.y, enums::PixelDataFormat::RGBA, enums::PixelDataType::UnsignedByte, screenshot.bits());
}); });
return result; return screenshot.mirrored(false, true);
} }
uint32_t OpenGLDisplayPlugin::getSceneTextureId() const { uint32_t OpenGLDisplayPlugin::getSceneTextureId() const {