glDeleteShader - 是顺序无关吗? [英] glDeleteShader - is the order irrelevant?

查看:411
本文介绍了glDeleteShader - 是顺序无关吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在OpenGL中, glAttachShader 的顺序是无关紧要的, glDeleteShader 我会说如果有一些动态内存分配正在进行,但也许这在opengl上下文中处理不同。

In OpenGL the order for glAttachShader is irrelevant, is this the same for glDeleteShader? I would say yes if there is some dynamic memory allocation is going on, but maybe this is handled different in the opengl context.

推荐答案

否,您删除着色器的顺序是 不重要。

No, the order that you delete your shaders is mostly unimportant.

我主要说,没有什么意义,删除您的着色器,然后将其附加到并链接您的GLSL程序。一旦程序被链接,你可以做任何你想要的着色器。

I say mostly, because it would not make much sense to delete your shader before you attach it to and link your GLSL program. Once the program is linked, however, you can do anything you want to the shaders.

OpenGL中的对象删除由驱动程序处理,不一定立即发生。它必须以这种方式工作,因为OpenGL可以排队仍然引用您尝试删除的对象的命令。如果立即删除它们,那么已经发出但尚未完成的命令将具有未定义的结果。相反,GL在 之后之后 时删除对象内存 c $>

Object deletion in OpenGL is handled by the driver and does not necessarily happen immediately. It has to work this way because OpenGL may queue up commands that still reference the object you are trying to delete. If it deleted them immediately, then commands that were already issued but not yet complete would have undefined results. Instead, GL deletes object memory at some time after you call glDelete* (...) when nothing else holds a reference to it.

当您调用 glDelete *(..)时,GL将立即执行释放对象名称,以便通过 glGen *(...)命令重新使用(并将其从当前上下文中解除绑定)。内存回收将不会发生,直到将来某个时候。

The only thing GL will immediately do when you call glDelete* (..) is release the object name for reuse by a glGen* (...) command (and unbind it from the current context). Memory reclamation will not happen until some point in the future.

这篇关于glDeleteShader - 是顺序无关吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆