diff options
Diffstat (limited to 'examples/widgets/painting/shared/fbopaintdevice.cpp')
-rw-r--r-- | examples/widgets/painting/shared/fbopaintdevice.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/examples/widgets/painting/shared/fbopaintdevice.cpp b/examples/widgets/painting/shared/fbopaintdevice.cpp index 305f4f2c2c..5875e6574b 100644 --- a/examples/widgets/painting/shared/fbopaintdevice.cpp +++ b/examples/widgets/painting/shared/fbopaintdevice.cpp @@ -24,11 +24,13 @@ QFboPaintDevice::QFboPaintDevice(const QSize &size, bool flipped, bool clearOnIn context()->functions()->glClearColor(0, 0, 0, 0); context()->functions()->glClear(GL_COLOR_BUFFER_BIT); } + m_resolvedFbo = new QOpenGLFramebufferObject(m_framebufferObject->size(), m_framebufferObject->attachment()); } QFboPaintDevice::~QFboPaintDevice() { delete m_framebufferObject; + delete m_resolvedFbo; delete m_surface; } @@ -40,12 +42,19 @@ void QFboPaintDevice::ensureActiveTarget() m_framebufferObject->bind(); } +GLuint QFboPaintDevice::texture() +{ + m_resolvedFbo->bind(); // to get the backing texture recreated if it was taken (in takeTexture) previously + QOpenGLFramebufferObject::blitFramebuffer(m_resolvedFbo, m_framebufferObject); + return m_resolvedFbo->texture(); +} + GLuint QFboPaintDevice::takeTexture() { - // We have multisamples so we can't just forward takeTexture(). - QOpenGLFramebufferObject resolvedFbo(m_framebufferObject->size(), m_framebufferObject->attachment()); - QOpenGLFramebufferObject::blitFramebuffer(&resolvedFbo, m_framebufferObject); - return resolvedFbo.takeTexture(); + m_resolvedFbo->bind(); // to get the backing texture recreated if it was taken (in takeTexture) previously + // We have multisamples so we can't just forward takeTexture(), have to resolve first. + QOpenGLFramebufferObject::blitFramebuffer(m_resolvedFbo, m_framebufferObject); + return m_resolvedFbo->takeTexture(); } QImage QFboPaintDevice::toImage() const |