Original Post
Hello, I have setup FBO depth stencil texture, and everything works fine, but problem is, when I try to bind that depth texture, and later bind that FBO again, then contents of stencil buffer is damaged (it looks, that it is rewriten by some depth values). My code looks somehow like this: Generation of FBO: glGenFramebuffersEXT(1, &m_gl_framebuffer); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_gl_framebuffer); glGenTextures(1,&depthTextureID); glBindTexture(GL_TEXTURE_2D,depthTextureID); glTexImage2D (GL_TEXTURE_2D,0,GL_DEPTH24_STENCIL8_EXT,800,600,0,GL_DEPTH_STENCIL_EXT,GL_UNSIGNED_INT_24_8_EXT, NULL); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, depthTextureID, 0); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, depthTextureID, 0); test for rewrite: glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_gl_framebuffer); glClearDepth(0.500000); glClearStencil(1); glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0); //Binding of texture - if commented, then stencil is ok! glActiveTextureARB(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D,depthTextureID); glActiveTextureARB(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D,0); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,m_gl_framebuffer); //<--- here stencil buffer is damaged! glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,0); If I dont bind that texture, then everything is OK :( Did anyone encounter this problem too? Thanks for help.