Skip to content

Commit

Permalink
libgui|GL: More options for configuring a GLFramebuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent d447747 commit fc5711f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
25 changes: 18 additions & 7 deletions doomsday/libs/gui/include/de/graphics/glframebuffer.h
Expand Up @@ -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<GLTexture *> colorTextures, GLTexture *depthStencilTex);
void configure(QList<GLTexture *> colorTextures,
GLTexture * depthStencilTex,
Flags missingRenderBuffers = ColorDepthStencil);

/**
* Changes the configuration of the render target. Any previously allocated
Expand Down
17 changes: 11 additions & 6 deletions doomsday/libs/gui/src/graphics/glframebuffer.cpp
Expand Up @@ -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<GLTexture *>({colorTex}), depthStencilTex);
configure(QList<GLTexture *>({colorTex}), depthStencilTex, missingRenderBuffers);
}

void GLFramebuffer::configure(QList<GLTexture *> colorTextures, GLTexture *depthStencilTex)
void GLFramebuffer::configure(QList<GLTexture *> colorTextures,
GLTexture * depthStencilTex,
Flags missingRenderBuffers)
{
LOG_AS("GLFramebuffer");

Expand Down Expand Up @@ -588,7 +592,7 @@ void GLFramebuffer::configure(QList<GLTexture *> 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);
}
Expand All @@ -600,9 +604,10 @@ void GLFramebuffer::configure(QList<GLTexture *> 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();
Expand Down

0 comments on commit fc5711f

Please sign in to comment.