From 2477b120ebaeed19516c54c0beaddd224fd633e9 Mon Sep 17 00:00:00 2001 From: SK83RJOSH Date: Mon, 18 Jan 2021 18:03:15 +0100 Subject: [PATCH] Depth texture should always create a stencil buffer --- src/gl/gl3device.cpp | 8 ++++---- src/gl/gl3raster.cpp | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/gl/gl3device.cpp b/src/gl/gl3device.cpp index 4ed7977..087b1ac 100644 --- a/src/gl/gl3device.cpp +++ b/src/gl/gl3device.cpp @@ -1274,7 +1274,7 @@ setFrameBuffer(Camera *cam) Gl3Raster *oldfb = PLUGINOFFSET(Gl3Raster, natzb->fboMate, nativeRasterOffset); if(oldfb->fbo){ bindFramebuffer(oldfb->fbo); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, 0, 0); + glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, 0, 0); bindFramebuffer(natfb->fbo); } oldfb->fboMate = nil; @@ -1283,15 +1283,15 @@ setFrameBuffer(Camera *cam) natzb->fboMate = fbuf; if(natfb->fbo){ if(gl3Caps.gles) - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, natzb->texid); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, natzb->texid); else - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, natzb->texid, 0); + glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, natzb->texid, 0); } } }else{ // remove z-buffer if(natfb->fboMate && natfb->fbo) - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, 0, 0); + glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, 0, 0); natfb->fboMate = nil; } } diff --git a/src/gl/gl3raster.cpp b/src/gl/gl3raster.cpp index a7437ed..abb0f98 100644 --- a/src/gl/gl3raster.cpp +++ b/src/gl/gl3raster.cpp @@ -233,12 +233,12 @@ rasterCreateZbuffer(Raster *raster) // have to use RBO on GLES!! glGenRenderbuffers(1, &natras->texid); glBindRenderbuffer(GL_RENDERBUFFER, natras->texid); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, raster->width, raster->height); + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, raster->width, raster->height); }else{ // TODO: set/check width, height, depth, format? - natras->internalFormat = GL_DEPTH_COMPONENT; - natras->format = GL_DEPTH_COMPONENT; - natras->type = GL_UNSIGNED_BYTE; + natras->internalFormat = GL_DEPTH_STENCIL; + natras->format = GL_DEPTH_STENCIL; + natras->type = GL_UNSIGNED_INT_24_8; natras->autogenMipmap = 0; @@ -735,7 +735,7 @@ destroyNativeRaster(void *object, int32 offset, int32) Gl3Raster *oldfb = GETGL3RASTEREXT(natras->fboMate); if(oldfb->fbo){ bindFramebuffer(oldfb->fbo); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, 0, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0); } oldfb->fboMate = nil; }