I’m trying to use the results of an fbo as input to a shader. However, it appears when I switch the attachments to the FBO, the original attachments get cleared.
I want to use the same FBO because I hear it is faster to switch textures than to switch FBOs.
So, I setup my FBO with two textures:
gl.glFramebufferTexture2DEXT(GL.GL_FRAMEBUFFER_EXT, GL.GL_COLOR_ATTACHMENT0_EXT, GL.GL_TEXTURE_2D, ftexture[0], 0);
…
gl.glFramebufferTexture2DEXT(GL.GL_FRAMEBUFFER_EXT, GL.GL_DEPTH_ATTACHMENT_EXT, GL.GL_TEXTURE_2D, fdepthtexture[0], 0);
And everything renders properly, until I want to attach two different textures to the FBO, and use the original textures as inputs for the fragment shader.
For example, this clears the original texture, when i try to unattach the texture:
gl.glFramebufferTexture2DEXT(GL.GL_FRAMEBUFFER_EXT, GL.GL_COLOR_ATTACHMENT0_EXT, GL.GL_TEXTURE_2D, 0, 0);
Or, this clears the original texture, when I try to attach another texture to the FBO (even without the line above):
gl.glFramebufferTexture2DEXT(GL.GL_FRAMEBUFFER_EXT, GL.GL_COLOR_ATTACHMENT0_EXT, GL.GL_TEXTURE_2D, anothertexure[0], 0);
So, is it not possible to attach different textures to an FBO and pass the orignals as inputs to a fragment shader?