Proper way to delete GLSL shader?

前端 未结 4 1485
失恋的感觉
失恋的感觉 2020-12-04 11:21

My code approaches GLSL shader management in the way, that it creates each shader and the associated program and deletes each shader and program. I recently read http://www.

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-04 11:50

    Yes. You can safely delete the shader then. In fact, this is the preferred way, because you have less maintenance. You need not keep track of what to delete, and you cannot forget to do it. And, it will still work.

    "Deleting" the shader, as with all OpenGL objects, merely sets a flag that says you don't need it any more. OpenGL will keep it around for as long as it needs it itself, and will do the actual delete any time later (most likely, but not necessarily, after the program is deleted).

提交回复
热议问题