From 06b86f68e8ddb1bbadd5adc14067f92c896ead93 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 10 Jun 2015 17:43:59 +0200 Subject: Support MRT in QOpenGLFramebufferObject MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce overloads in the API to allow specifying multiple color attachment sizes and formats. When these are in use and MRT is supported, a texture or renderbuffer is created for each of GL_COLOR_ATTACHMENT0, 1, 2, ... [ChangeLog] Added support for multiple render targets in QOpenGLFramebufferObject Task-number: QTBUG-39235 Change-Id: Ie7cfd81d1b796a9166b80dff7513aafe0120d53d Reviewed-by: Jørgen Lind --- src/gui/opengl/qopenglframebufferobject_p.h | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'src/gui/opengl/qopenglframebufferobject_p.h') diff --git a/src/gui/opengl/qopenglframebufferobject_p.h b/src/gui/opengl/qopenglframebufferobject_p.h index 7f0068dfc4..6c45fda57f 100644 --- a/src/gui/opengl/qopenglframebufferobject_p.h +++ b/src/gui/opengl/qopenglframebufferobject_p.h @@ -102,32 +102,41 @@ public: class QOpenGLFramebufferObjectPrivate { public: - QOpenGLFramebufferObjectPrivate() : fbo_guard(0), texture_guard(0), depth_buffer_guard(0) - , stencil_buffer_guard(0), color_buffer_guard(0) + QOpenGLFramebufferObjectPrivate() : fbo_guard(0), depth_buffer_guard(0) + , stencil_buffer_guard(0) , valid(false) {} ~QOpenGLFramebufferObjectPrivate() {} - void init(QOpenGLFramebufferObject *q, const QSize& sz, + void init(QOpenGLFramebufferObject *q, const QSize &size, QOpenGLFramebufferObject::Attachment attachment, - GLenum internal_format, GLenum texture_target, + GLenum texture_target, GLenum internal_format, GLint samples = 0, bool mipmap = false); - void initTexture(GLenum target, GLenum internal_format, const QSize &size, bool mipmap); - void initAttachments(QOpenGLContext *ctx, QOpenGLFramebufferObject::Attachment attachment); + void initTexture(int idx); + void initColorBuffer(int idx, GLint *samples); + void initDepthStencilAttachments(QOpenGLContext *ctx, QOpenGLFramebufferObject::Attachment attachment); bool checkFramebufferStatus(QOpenGLContext *ctx) const; QOpenGLSharedResourceGuard *fbo_guard; - QOpenGLSharedResourceGuard *texture_guard; QOpenGLSharedResourceGuard *depth_buffer_guard; QOpenGLSharedResourceGuard *stencil_buffer_guard; - QOpenGLSharedResourceGuard *color_buffer_guard; GLenum target; - QSize size; + QSize dsSize; QOpenGLFramebufferObjectFormat format; int requestedSamples; uint valid : 1; QOpenGLFramebufferObject::Attachment fbo_attachment; QOpenGLExtensions funcs; + struct ColorAttachment { + ColorAttachment() : internalFormat(0), guard(0) { } + ColorAttachment(const QSize &size, GLenum internalFormat) + : size(size), internalFormat(internalFormat), guard(0) { } + QSize size; + GLenum internalFormat; + QOpenGLSharedResourceGuard *guard; + }; + QVector colorAttachments; + inline GLuint fbo() const { return fbo_guard ? fbo_guard->id() : 0; } }; -- cgit v1.2.3