Deleting textures in opengl

空扰寡人 提交于 2019-11-29 15:05:37
Kaiged

Depending on what manages your OpenGL context, you may not need to delete the textures. For an example, see this question.

There does seem to be consensus, though, that it is good to clean up after yourself, but be careful when using C++ RAII to do so! If a C++ object that manages an OpenGL object via RAII is created or destroyed without an OpenGL context, undefined behavior will occur.

See: The Object Oriented Language Problem

The OpenGL API and OpenGL objects don't map intuitively to C++ OOP principles.

OpenGL resources are frees implicitly once all contexts with access to them are destroyed. OpenGL contexts of a process get destroyed when the client terminates; however in the case of indirect GLX context objects may be shared among X11 clients, so they may be freed only after the last client with access to them terminates.

Nevertheless it's always a good practice to clean up after yourself.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!