I render to texture and attach my own depth buffer that has texture target. However, after I finish rendering I would like to set original depth buffer back.
To start rendering to texture I do:
glGetIntegerv(GL_RENDERBUFFER_BINDING, &bindedDepthBuffer); //returns 0
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &bindedFrameBuffer); //returns 0
glBindFramebuffer(GL_FRAMEBUFFER, rttFboId);
glBindRenderbuffer(GL_RENDERBUFFER, rttDepthId);
glViewport(0, 0, rttViewPortWidth, rttViewPortHeight);
... render scene
glViewport(0, 0, origWidth, origHeight);
glBindFramebuffer(GL_FRAMEBUFFER, bindedFrameBuffer);
Now after I do:
glBindRenderbuffer(GL_RENDERBUFFER, bindedDepthBuffer);
the original depth buffer stops working and it seems as its content is empty (everything that is rendered after this point behave like the depth buffer has been cleared). This problem occurs only on some OpenGL ES devices with Android and I dont know what can cause this.