From fc5711f0db806b267c8b0aea4dfa7375480f5105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= Date: Wed, 21 Feb 2018 09:01:13 +0200 Subject: [PATCH] libgui|GL: More options for configuring a GLFramebuffer --- .../gui/include/de/graphics/glframebuffer.h | 25 +++++++++++++------ .../libs/gui/src/graphics/glframebuffer.cpp | 17 ++++++++----- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/doomsday/libs/gui/include/de/graphics/glframebuffer.h b/doomsday/libs/gui/include/de/graphics/glframebuffer.h index 133a52c806..b836e3bf23 100644 --- a/doomsday/libs/gui/include/de/graphics/glframebuffer.h +++ b/doomsday/libs/gui/include/de/graphics/glframebuffer.h @@ -141,22 +141,33 @@ class LIBGUI_PUBLIC GLFramebuffer : public Asset * values and one for depth/stencil values. * * If @a colorTex or @a depthStencilTex is omitted, a renderbuffer will be - * created in its place. + * created in its place (depending on @a missingRenderBuffers). * * Any previous attachments are released. * - * @param colorTex Texture for color values. - * @param depthStencilTex Texture for depth/stencil values. + * @param colorTex Texture for color values. + * @param depthStencilTex Texture for depth/stencil values. + * @param missingRenderBuffers Create renderbuffers for attachments where + * texture has not been specified. */ - void configure(GLTexture *colorTex, GLTexture *depthStencilTex); + void configure(GLTexture *colorTex, + GLTexture *depthStencilTex, + Flags missingRenderBuffers = ColorDepthStencil); /** * Reconfigures the framebuffer with multiple textures. * - * @param colorTextures Textures for color attachments. - * @param depthStencilTex Texture for depth/stencil values. + * If @a colorTex or @a depthStencilTex is omitted, a renderbuffer will be + * created in its place (depending on @a missingRenderBuffers). + * + * @param colorTextures Textures for color attachments. + * @param depthStencilTex Texture for depth/stencil values. + * @param missingRenderBuffers Create renderbuffers for attachments where + * texture has not been specified. */ - void configure(QList colorTextures, GLTexture *depthStencilTex); + void configure(QList colorTextures, + GLTexture * depthStencilTex, + Flags missingRenderBuffers = ColorDepthStencil); /** * Changes the configuration of the render target. Any previously allocated diff --git a/doomsday/libs/gui/src/graphics/glframebuffer.cpp b/doomsday/libs/gui/src/graphics/glframebuffer.cpp index 7b1d985c02..8affbd39cd 100644 --- a/doomsday/libs/gui/src/graphics/glframebuffer.cpp +++ b/doomsday/libs/gui/src/graphics/glframebuffer.cpp @@ -553,12 +553,16 @@ void GLFramebuffer::configure(Vec2ui const &size, Flags flags, int sampleCount) LIBGUI_ASSERT_GL_OK(); } -void GLFramebuffer::configure(GLTexture *colorTex, GLTexture *depthStencilTex) +void GLFramebuffer::configure(GLTexture *colorTex, + GLTexture *depthStencilTex, + Flags missingRenderBuffers) { - configure(QList({colorTex}), depthStencilTex); + configure(QList({colorTex}), depthStencilTex, missingRenderBuffers); } -void GLFramebuffer::configure(QList colorTextures, GLTexture *depthStencilTex) +void GLFramebuffer::configure(QList colorTextures, + GLTexture * depthStencilTex, + Flags missingRenderBuffers) { LOG_AS("GLFramebuffer"); @@ -588,7 +592,7 @@ void GLFramebuffer::configure(QList colorTextures, GLTexture *depth DENG2_ASSERT(d->size == colorTex->size()); d->attachTexture(*colorTex, GL_COLOR_ATTACHMENT0 + i); } - if (colorTextures.isEmpty()) + if (colorTextures.isEmpty() && missingRenderBuffers.testFlag(Color0)) { d->attachRenderbuffer(Impl::ColorBuffer0, GL_RGBA8, GL_COLOR_ATTACHMENT0); } @@ -600,9 +604,10 @@ void GLFramebuffer::configure(QList colorTextures, GLTexture *depth DENG2_ASSERT(d->size == depthStencilTex->size()); d->attachTexture(*depthStencilTex, GL_DEPTH_STENCIL_ATTACHMENT); } - else + else if (missingRenderBuffers.testFlag(DepthStencil)) { - d->attachRenderbuffer(Impl::DepthStencilBuffer, GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL_ATTACHMENT); + d->attachRenderbuffer( + Impl::DepthStencilBuffer, GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL_ATTACHMENT); } LIBGUI_ASSERT_GL_OK();