diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-12-15 01:20:53 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-12-15 01:20:57 +0000 |
commit | 582b43ff308eecbdcaf0ab14994a0ddbdba1b701 (patch) | |
tree | cad85844015f526102b28c3bc61a2116eb8818fa /gfx/gl | |
parent | Basic support for saving intermediate render buffers (diff) | |
download | ilt-582b43ff308eecbdcaf0ab14994a0ddbdba1b701.tar.bz2 ilt-582b43ff308eecbdcaf0ab14994a0ddbdba1b701.tar.xz ilt-582b43ff308eecbdcaf0ab14994a0ddbdba1b701.zip |
Support setting framebuffer texture format
Renames format to iformat to differentiate internal format from format
Diffstat (limited to 'gfx/gl')
-rw-r--r-- | gfx/gl/sceneRenderer.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/gfx/gl/sceneRenderer.cpp b/gfx/gl/sceneRenderer.cpp index 582c28c..541af43 100644 --- a/gfx/gl/sceneRenderer.cpp +++ b/gfx/gl/sceneRenderer.cpp @@ -22,25 +22,25 @@ SceneRenderer::SceneRenderer(ScreenAbsCoord s, GLuint o) : VertexArrayObject {displayVAO}.addAttribs<glm::i8vec4>(displayVBO, displayVAOdata); glBindFramebuffer(GL_FRAMEBUFFER, gBuffer); - const auto configuregdata - = [this](const GLuint data, const std::initializer_list<GLint> formats, const GLenum attachment) { - glBindTexture(GL_TEXTURE_2D, data); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - for (const auto format : formats) { - glTexImage2D(GL_TEXTURE_2D, 0, format, size.x, size.y, 0, GL_RGB, GL_BYTE, nullptr); + const auto configuregdata = [this](const GLuint data, const std::initializer_list<GLint> iformats, + const GLenum format, const GLenum attachment) { + glBindTexture(GL_TEXTURE_2D, data); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + for (const auto iformat : iformats) { + glTexImage2D(GL_TEXTURE_2D, 0, iformat, size.x, size.y, 0, format, GL_BYTE, nullptr); - glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, data, 0); - if (glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE) { - return format; - } - } - throw std::runtime_error("Framebuffer could not be completed!"); - }; - configuregdata(gPosition, {GL_RGB32F}, GL_COLOR_ATTACHMENT0); - configuregdata(gNormal, {GL_RGB8_SNORM, GL_RGB16F}, GL_COLOR_ATTACHMENT1); - configuregdata(gAlbedoSpec, {GL_RGB8}, GL_COLOR_ATTACHMENT2); - configuregdata(gIllumination, {GL_RGB8}, GL_COLOR_ATTACHMENT3); + glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, data, 0); + if (glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE) { + return iformat; + } + } + throw std::runtime_error("Framebuffer could not be completed!"); + }; + configuregdata(gPosition, {GL_RGB32F}, GL_RGB, GL_COLOR_ATTACHMENT0); + configuregdata(gNormal, {GL_RGB8_SNORM, GL_RGB16F}, GL_RGB, GL_COLOR_ATTACHMENT1); + configuregdata(gAlbedoSpec, {GL_RGB8}, GL_RGB, GL_COLOR_ATTACHMENT2); + configuregdata(gIllumination, {GL_RGB8}, GL_RGB, GL_COLOR_ATTACHMENT3); glBindRenderbuffer(GL_RENDERBUFFER, depth); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, size.x, size.y); |