简体   繁体   中英

OSX OpenGL depth stencil combination

I am trying to create a frame buffer with a GL_DEPTH_STENCIL_ATTACHMENT TEXTURE on OSX 10.11.5 with an OpenGL 3.2 SDL context. It seems that the following line creates OpenGL error 1280:

glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,  GL_TEXTURE_2D, depthTexture, 0);

This texture is generated as follows:

glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH32F_STENCIL8, width, height, 0, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, 0);

I know this is an OSX issue since this code used to work perfectly on my old Arch Linux computer. I did read the official tutorial and there is no mention of a combined depth and stencil texture attachment. So is this functionality just not supported or am I doing it wrong? If this functionality is not supported, then what should I do as an alternative? Create 2 separate depth and stencil textures?

Never sorry about this, but it turns out I was debugging wrong. OSX does support a stencil/depth hybrid even though Apple's documentation doesn't have much information on it. My error actually came from the next line, which was as follows:

glDrawBuffers(textureCount, allColorBuffers);

Which was wrong because texCount included the depth texture along with all my color buffers. So changing textureCount to textureCount-1 completely solved this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM