user1063364
user1063364

Reputation: 917

Opengl ES 2.0 glDeleteFramebuffers after drawing to texture

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

Answers (1)

Columbo
Columbo

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

Related Questions