src/opengl/qglframebufferobject.cpp
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
child 37 758a864f9613
--- a/src/opengl/qglframebufferobject.cpp	Tue Jul 06 15:10:48 2010 +0300
+++ b/src/opengl/qglframebufferobject.cpp	Wed Aug 18 10:37:55 2010 +0300
@@ -1024,6 +1024,36 @@
 }
 
 /*!
+    \fn bool QGLFramebufferObject::bindDefault()
+    \internal
+
+    Switches rendering back to the default, windowing system provided
+    framebuffer.
+    Returns true upon success, false otherwise.
+
+    \sa bind(), release()
+*/
+bool QGLFramebufferObject::bindDefault()
+{
+    QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext());
+
+    if (ctx) {
+        bool ext_detected = (QGLExtensions::glExtensions() & QGLExtensions::FramebufferObject);
+        if (!ext_detected || (ext_detected && !qt_resolve_framebufferobject_extensions(ctx)))
+            return false;
+
+        ctx->d_ptr->current_fbo = ctx->d_ptr->default_fbo;
+        glBindFramebuffer(GL_FRAMEBUFFER_EXT, ctx->d_ptr->default_fbo);
+#ifdef QT_DEBUG
+    } else {
+        qWarning("QGLFramebufferObject::bindDefault() called without current context.");
+#endif
+    }
+
+    return ctx != 0;
+}
+
+/*!
     \fn bool QGLFramebufferObject::hasOpenGLFramebufferObjects()
 
     Returns true if the OpenGL \c{GL_EXT_framebuffer_object} extension