diff options
author | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-09-10 06:28:20 (GMT) |
---|---|---|
committer | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-09-10 06:28:20 (GMT) |
commit | cea0b5db7f16177882bbfbbe7b4f92307b045bf7 (patch) | |
tree | 73f55e2b2ed97f07233ca4382c0d2d3fcaa982fd /src/opengl/qglframebufferobject.cpp | |
parent | 66dc9221163a6b225cdfa351b8df7a01f6ce7bf0 (diff) | |
download | Qt-cea0b5db7f16177882bbfbbe7b4f92307b045bf7.zip Qt-cea0b5db7f16177882bbfbbe7b4f92307b045bf7.tar.gz Qt-cea0b5db7f16177882bbfbbe7b4f92307b045bf7.tar.bz2 |
Return the correct QGLFormat to the OpenGL1 paint engine for FBO's
QGLPaintDevice::format() was returning the context's format, not
the format of the window surface's FBO. This caused the OpenGL1
paint engine to think that the window didn't have depth and
stencil buffers, even though the FBO most certainly did.
This change makes QGLPaintDevice::format() virtual and overrides it
in QGLFBOGLPaintDevice to return an updated format that includes
the context parameters plus the extra features that the FBO supports.
Reviewed-by: Tom Cooksey
Diffstat (limited to 'src/opengl/qglframebufferobject.cpp')
-rw-r--r-- | src/opengl/qglframebufferobject.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 094f675..f15aa01 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -299,10 +299,21 @@ bool QGLFramebufferObjectFormat::operator!=(const QGLFramebufferObjectFormat& ot return !(*this == other); } -void QGLFBOGLPaintDevice::setFBO(QGLFramebufferObject* f) +void QGLFBOGLPaintDevice::setFBO(QGLFramebufferObject* f, + QGLFramebufferObject::Attachment attachment) { fbo = f; m_thisFBO = fbo->d_func()->fbo; // This shouldn't be needed + + // The context that the fbo was created in may not have depth + // and stencil buffers, but the fbo itself might. + fboFormat = QGLContext::currentContext()->format(); + if (attachment == QGLFramebufferObject::CombinedDepthStencil) { + fboFormat.setDepth(true); + fboFormat.setStencil(true); + } else if (attachment == QGLFramebufferObject::Depth) { + fboFormat.setDepth(true); + } } void QGLFBOGLPaintDevice::ensureActiveTarget() @@ -395,7 +406,7 @@ void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz, glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER_EXT, fbo); - glDevice.setFBO(q); + glDevice.setFBO(q, attachment); QT_CHECK_GLERROR(); // init texture |