Merge pull request #46 from SK83RJOSH/stencil-fix

Bug Fix: Use D24S8 explicitly in GL3 driver
This commit is contained in:
aap 2021-01-19 18:12:42 +01:00 committed by GitHub
commit 3c18728211
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 9 deletions

View File

@ -1274,7 +1274,7 @@ setFrameBuffer(Camera *cam)
Gl3Raster *oldfb = PLUGINOFFSET(Gl3Raster, natzb->fboMate, nativeRasterOffset); Gl3Raster *oldfb = PLUGINOFFSET(Gl3Raster, natzb->fboMate, nativeRasterOffset);
if(oldfb->fbo){ if(oldfb->fbo){
bindFramebuffer(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); bindFramebuffer(natfb->fbo);
} }
oldfb->fboMate = nil; oldfb->fboMate = nil;
@ -1283,15 +1283,15 @@ setFrameBuffer(Camera *cam)
natzb->fboMate = fbuf; natzb->fboMate = fbuf;
if(natfb->fbo){ if(natfb->fbo){
if(gl3Caps.gles) 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 else
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, natzb->texid, 0); glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, natzb->texid, 0);
} }
} }
}else{ }else{
// remove z-buffer // remove z-buffer
if(natfb->fboMate && natfb->fbo) 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; natfb->fboMate = nil;
} }
} }

View File

@ -233,12 +233,12 @@ rasterCreateZbuffer(Raster *raster)
// have to use RBO on GLES!! // have to use RBO on GLES!!
glGenRenderbuffers(1, &natras->texid); glGenRenderbuffers(1, &natras->texid);
glBindRenderbuffer(GL_RENDERBUFFER, 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{ }else{
// TODO: set/check width, height, depth, format? // TODO: set/check width, height, depth, format?
natras->internalFormat = GL_DEPTH_COMPONENT; natras->internalFormat = GL_DEPTH_STENCIL;
natras->format = GL_DEPTH_COMPONENT; natras->format = GL_DEPTH_STENCIL;
natras->type = GL_UNSIGNED_BYTE; natras->type = GL_UNSIGNED_INT_24_8;
natras->autogenMipmap = 0; natras->autogenMipmap = 0;
@ -735,7 +735,7 @@ destroyNativeRaster(void *object, int32 offset, int32)
Gl3Raster *oldfb = GETGL3RASTEREXT(natras->fboMate); Gl3Raster *oldfb = GETGL3RASTEREXT(natras->fboMate);
if(oldfb->fbo){ if(oldfb->fbo){
bindFramebuffer(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; oldfb->fboMate = nil;
} }