PDA

View Full Version : Does glFramebufferTexture2D reset the previous attached texture?



ref2401
10-02-2015, 04:42 AM
When I'm attaching a texture or detaching the previous one the detached texture is reset to zero. Strictly speaking there are not only zero values. There are some garbage values too. Is it Ok? I can't find anything about it in opengl reference.

//pseudocode:
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 1);
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 1, 0);
glDrawBuffer(GL_COLOR_ATTACHMENT0);
glReadBuffer(GL_NONE);
GLenum fbStatus = glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
glViewport(0, 0, WIDTH, HEIGHT);
glClear(GL_COLOR_BUFFER_BIT);

... do rendering here ... // no the texture #1 contains the proper result

// If I uncomment one of the following lines then the texture #1 will be reset.
// glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); // detaching the texture
// glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 2, 0); // attaching another texture

ref2401
10-02-2015, 05:41 AM
Finally I've figured it out. Spent 3 days :(
There is no issue with the glFramebufferTexture2D function or with opengl call sequence. Those bloody tools (gDEBugger & AMD CodeXL) just show me the incorrect result.
I'm sorry for wasting your time mates.