diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2009-11-06 21:55:48 (GMT) |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2009-11-06 21:55:48 (GMT) |
commit | 360a51d64c607f5efae7a4f25a9a519424399b69 (patch) | |
tree | 874eb46ab469865ce9d9b58b9d1cf86d49e5bd1c /src/opengl/qglframebufferobject.cpp | |
parent | 7359baee83f6691c31a0a14ffd6f6cc147ed71fd (diff) | |
parent | 2b91557c93354b766c78cbc4ab48bcd58207bf1a (diff) | |
download | Qt-360a51d64c607f5efae7a4f25a9a519424399b69.zip Qt-360a51d64c607f5efae7a4f25a9a519424399b69.tar.gz Qt-360a51d64c607f5efae7a4f25a9a519424399b69.tar.bz2 |
Merge remote branch 'mainline/4.6' into 4.6
Diffstat (limited to 'src/opengl/qglframebufferobject.cpp')
-rw-r--r-- | src/opengl/qglframebufferobject.cpp | 86 |
1 files changed, 23 insertions, 63 deletions
diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 7374594..d79283e 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -342,39 +342,6 @@ QGLContext *QGLFBOGLPaintDevice::context() const return fboContext; } -void QGLFBOGLPaintDevice::ensureActiveTarget() -{ - if (QGLContext::currentContext() != context()) - context()->makeCurrent(); - - QGLContext* ctx = const_cast<QGLContext*>(QGLContext::currentContext()); - Q_ASSERT(ctx); - const GLuint fboId = fbo->d_func()->fbo(); - if (ctx->d_func()->current_fbo != fboId) { - ctx->d_func()->current_fbo = fboId; - glBindFramebuffer(GL_FRAMEBUFFER_EXT, fboId); - } -} - -void QGLFBOGLPaintDevice::beginPaint() -{ - if (QGLContext::currentContext() != context()) - context()->makeCurrent(); - - // We let QFBO track the previously bound FBO rather than doing it - // ourselves here. This has the advantage that begin/release & bind/end - // work as expected. - wasBound = fbo->isBound(); - if (!wasBound) - fbo->bind(); -} - -void QGLFBOGLPaintDevice::endPaint() -{ - if (!wasBound) - fbo->release(); -} - bool QGLFramebufferObjectPrivate::checkFramebufferStatus() const { QGL_FUNCP_CONTEXT; @@ -879,13 +846,6 @@ bool QGLFramebufferObject::isValid() const framebuffer to this framebuffer object. Returns true upon success, false otherwise. - Since 4.6: if another QGLFramebufferObject instance was already bound - to the current context, then its handle() will be remembered and - automatically restored when release() is called. This allows multiple - framebuffer rendering targets to be stacked up. It is important that - release() is called on the stacked framebuffer objects in the reverse - order of the calls to bind(). - \sa release() */ bool QGLFramebufferObject::bind() @@ -896,17 +856,18 @@ bool QGLFramebufferObject::bind() QGL_FUNC_CONTEXT; if (!ctx) return false; // Context no longer exists. + const QGLContext *current = QGLContext::currentContext(); +#ifdef QT_DEBUG + if (!current || + QGLContextPrivate::contextGroup(current) != QGLContextPrivate::contextGroup(ctx)) + { + qWarning("QGLFramebufferObject::bind() called from incompatible context"); + } +#endif glBindFramebuffer(GL_FRAMEBUFFER_EXT, d->fbo()); d->valid = d->checkFramebufferStatus(); - const QGLContext *context = QGLContext::currentContext(); - if (d->valid && context) { - Q_ASSERT(QGLContextPrivate::contextGroup(context) == QGLContextPrivate::contextGroup(ctx)); - // Save the previous setting to automatically restore in release(). - if (context->d_ptr->current_fbo != d->fbo()) { - d->previous_fbo = context->d_ptr->current_fbo; - context->d_ptr->current_fbo = d->fbo(); - } - } + if (d->valid && current) + current->d_ptr->current_fbo = d->fbo(); return d->valid; } @@ -917,30 +878,29 @@ bool QGLFramebufferObject::bind() framebuffer. Returns true upon success, false otherwise. - Since 4.6: if another QGLFramebufferObject instance was already bound - to the current context when bind() was called, then this function will - automatically re-bind it to the current context. - \sa bind() */ bool QGLFramebufferObject::release() { if (!isValid()) return false; - Q_D(QGLFramebufferObject); QGL_FUNC_CONTEXT; if (!ctx) return false; // Context no longer exists. - const QGLContext *context = QGLContext::currentContext(); - if (context) { - Q_ASSERT(QGLContextPrivate::contextGroup(context) == QGLContextPrivate::contextGroup(ctx)); - // Restore the previous setting for stacked framebuffer objects. - if (d->previous_fbo != context->d_ptr->current_fbo) { - context->d_ptr->current_fbo = d->previous_fbo; - glBindFramebuffer(GL_FRAMEBUFFER_EXT, d->previous_fbo); - } - d->previous_fbo = 0; + const QGLContext *current = QGLContext::currentContext(); + +#ifdef QT_DEBUG + if (!current || + QGLContextPrivate::contextGroup(current) != QGLContextPrivate::contextGroup(ctx)) + { + qWarning("QGLFramebufferObject::release() called from incompatible context"); + } +#endif + + if (current) { + current->d_ptr->current_fbo = 0; + glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); } return true; |