diff options
| author | Tom Englund <tomenglund26@gmail.com> | 2026-01-23 21:09:39 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-23 20:09:39 +0000 |
| commit | 2a2c2b0e281c0419d6daee79f16a587c3701be8f (patch) | |
| tree | 310ba26f476177ab9ae4982229450f04b7df4b29 /src/render/Framebuffer.cpp | |
| parent | 64db62d7e2685d62cbab51a1a7cb7f2cf38a1b32 (diff) | |
opengl/fb: use GL_DEPTH24_STENCIL8 instead of GL_STENCIL_INDEX8 (#13067)
older drivers lack support for GL_STENCIL_INDEX8 so use
GL_DEPTH24_STENCIL8 but explicitly disable the depth.
Diffstat (limited to 'src/render/Framebuffer.cpp')
| -rw-r--r-- | src/render/Framebuffer.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/render/Framebuffer.cpp b/src/render/Framebuffer.cpp index cfafd4be..23bbd643 100644 --- a/src/render/Framebuffer.cpp +++ b/src/render/Framebuffer.cpp @@ -38,8 +38,11 @@ bool CFramebuffer::alloc(int w, int h, uint32_t drmFormat) { if (m_stencilTex) { m_stencilTex->bind(); - glTexImage2D(GL_TEXTURE_2D, 0, GL_STENCIL_INDEX8, w, h, 0, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, nullptr); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_stencilTex->m_texID, 0); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, w, h, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, nullptr); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_stencilTex->m_texID, 0); + + glDisable(GL_DEPTH_TEST); + glDepthMask(GL_FALSE); } auto status = glCheckFramebufferStatus(GL_FRAMEBUFFER); @@ -63,11 +66,14 @@ void CFramebuffer::addStencil(SP<CTexture> tex) { m_stencilTex = tex; m_stencilTex->bind(); - glTexImage2D(GL_TEXTURE_2D, 0, GL_STENCIL_INDEX8, m_size.x, m_size.y, 0, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, nullptr); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, m_size.x, m_size.y, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, nullptr); glBindFramebuffer(GL_FRAMEBUFFER, m_fb); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_stencilTex->m_texID, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_stencilTex->m_texID, 0); + + glDisable(GL_DEPTH_TEST); + glDepthMask(GL_FALSE); auto status = glCheckFramebufferStatus(GL_FRAMEBUFFER); RASSERT((status == GL_FRAMEBUFFER_COMPLETE), "Failed adding a stencil to fbo!", status); |
