i am implementing render to texture concept and have doubt regarding scope of a FBOs. After i am done with glDrawArrays call on default FBO with render to texture, i am deleting texture and non default FBO. Then i am calling glReadPixels to read contents on default FBO. So, my question is am i doing it right i mean should i call readpixel before deleting FBO and texture?
What i was assuming that after drawing it on default FBO we dont need non default FBO and texture but later some developer of OpenGL told me i am doing some strange things in my application referring to above. Please help me to understand this.
Here are the steps i am following:
- create a framebuffer object and attach a suitable texture as color attachment
- bind and clear the FBO
- render some primitives
- unbind the FBO thus switiching back to the system FBO
- bind the texture used as color attachment
- Render on system FBO with texture created above.
- delete texture and FBO created.
- glReadpixel from system FBO.
Now, as i have rendered on system FBO and it. why do we still need that texture and other FBO which were used as textures?
Note: I am using terms system FBO to just differentiate between two FBOs its my terminology.