Does iOS5 support both GL_STENCIL_INDEX and GL_STENCIL_INDEX8?

烈酒焚心 提交于 2019-12-08 20:10:44

It seems that in OpenGL ES 2.0 at least on iOS (not sure for other OS) you have to create combine the depth buffer and the stencil buffer. I listed all the extensions supported on my device (iPhone 4 with iOS 5.0.1) and the only one related to the stencil buffer is :

GL_OES_packed_depth_stencil

This suggests that you would have to create a combo depth+stencil buffer (taken from the iPhone 3D Programming book)

// Create a packed depth stencil buffer.
GLuint depthStencil;
glGenRenderbuffersOES(1, &depthStencil);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthStencil);
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH24_STENCIL8_OES, width, height);

// Create the framebuffer object.
GLuint framebuffer;
glGenFramebuffersOES(1, &framebuffer);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, framebuffer);
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES,
                             GL_RENDERBUFFER_OES, color);
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES,
                                GL_RENDERBUFFER_OES, depthStencil);
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_STENCIL_ATTACHMENT_OES,
                             GL_RENDERBUFFER_OES, depthStencil);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, color);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!