How to create a FBO with stencil buffer in OpenGL ES 2.0?

前端 未结 2 1359
面向向阳花
面向向阳花 2020-12-31 10:30

I need stencil buffer on 3GS to render planar shadow, and polygon offset won\'t work prefect, still has z-fighting problem. So I use stencil buffer to make the shadow correc

2条回答
  •  渐次进展
    2020-12-31 11:11

    In OpenGL ES 2.0 on iOS, you have to create a combined depth and stencil renderbuffer using GL_DEPTH24_STENCIL8_OES, and then attach it to the bound framebuffer as both GL_DEPTH_ATTACHMENT and GL_STENCIL_ATTACHMENT.

    glGenRenderbuffers(1, &depthStencilRenderbuffer);
    glBindRenderbuffer(GL_RENDERBUFFER, depthStencilRenderbuffer);
    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthStencilRenderbuffer);
    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthStencilRenderbuffer);
    

提交回复
热议问题