feat: Depth textures are created with a stencil component

This commit is contained in:
Vsevolod Kremianskii 2021-02-08 21:24:57 +07:00
parent a34c73e095
commit d3ff68b6d7
2 changed files with 3 additions and 3 deletions

View file

@ -61,9 +61,9 @@ void Framebuffer::init() {
} }
} }
if (_cubeMapDepthBuffer) { if (_cubeMapDepthBuffer) {
glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, _depthBuffer->textureId(), 0); glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, _depthBuffer->textureId(), 0);
} else { } else {
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, _depthBuffer->textureId(), 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, _depthBuffer->textureId(), 0);
} }
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {

View file

@ -174,7 +174,7 @@ void Texture::fillTarget(uint32_t target, int level, int width, int height, cons
glCompressedTexImage2D(target, level, getInternalPixelFormat(), width, height, 0, size, pixels); glCompressedTexImage2D(target, level, getInternalPixelFormat(), width, height, 0, size, pixels);
break; break;
case PixelFormat::Depth: case PixelFormat::Depth:
glTexImage2D(target, level, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, pixels); glTexImage2D(target, level, GL_DEPTH24_STENCIL8, width, height, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, pixels);
break; break;
default: default:
throw logic_error("Unsupported pixel format: " + to_string(static_cast<int>(_pixelFormat))); throw logic_error("Unsupported pixel format: " + to_string(static_cast<int>(_pixelFormat)));