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

前端 未结 2 1358
面向向阳花
面向向阳花 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);
    
    0 讨论(0)
  • 2020-12-31 11:24

    Just a note, if you are using GLKView, it is as simple as

    view.drawableStencilFormat = GLKViewDrawableStencilFormat8;

    where view is: GLKView*

    0 讨论(0)
提交回复
热议问题