summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/opengl/qglframebufferobject.cpp15
-rw-r--r--src/opengl/qglframebufferobject_p.h5
-rw-r--r--src/opengl/qglpaintdevice_p.h2
3 files changed, 18 insertions, 4 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
diff --git a/src/opengl/qglframebufferobject_p.h b/src/opengl/qglframebufferobject_p.h
index c11c496..f80209d 100644
--- a/src/opengl/qglframebufferobject_p.h
+++ b/src/opengl/qglframebufferobject_p.h
@@ -110,15 +110,18 @@ public:
virtual QPaintEngine* paintEngine() const {return fbo->paintEngine();}
virtual QSize size() const {return fbo->size();}
virtual QGLContext* context() const {return const_cast<QGLContext *>(QGLContext::currentContext());}
+ virtual QGLFormat format() const {return fboFormat;}
virtual void ensureActiveTarget();
virtual void beginPaint();
virtual void endPaint();
- void setFBO(QGLFramebufferObject* f);
+ void setFBO(QGLFramebufferObject* f,
+ QGLFramebufferObject::Attachment attachment);
private:
bool wasBound;
QGLFramebufferObject* fbo;
+ QGLFormat fboFormat;
};
class QGLFramebufferObjectPrivate
diff --git a/src/opengl/qglpaintdevice_p.h b/src/opengl/qglpaintdevice_p.h
index 66b24a9..1e7ba8d 100644
--- a/src/opengl/qglpaintdevice_p.h
+++ b/src/opengl/qglpaintdevice_p.h
@@ -73,7 +73,7 @@ public:
virtual void endPaint();
virtual QGLContext* context() const = 0;
- QGLFormat format() const;
+ virtual QGLFormat format() const;
virtual QSize size() const = 0;
// returns the QGLPaintDevice for the given QPaintDevice