summaryrefslogtreecommitdiffstats
path: root/src/opengl/qglframebufferobject.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/opengl/qglframebufferobject.cpp')
-rw-r--r--src/opengl/qglframebufferobject.cpp86
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;