Reputation: 917
I render to texture using frame buffer. But I am not sure when should I correctly use glDeleteFramebuffers
. Should fbo exist while texture exists, or can I safely call glDeleteFramebuffers
after last draw to texture.
Upvotes: 2
Views: 453
Reputation: 6766
You can safely call glDeleteFramebuffers after the last draw to texture. However, I would work on the assumption that creating and destroying framebuffers is expensive, so I would only do it if I knew for sure I wouldn't be rendering to that texture ever again.
I have experienced bugs on some Android GLES drivers where I've had to detach the texture from the framebuffer prior to deleting the framebuffer so I'd recommend you do that as a precaution:
glBindFramebuffer(GL_FRAMEBUFFER, frameBuffer);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
Upvotes: 2