为什么glObjectLabel只对GL_纹理失败?

wvt8vs2t  于 2022-10-18  发布在  其他
关注(0)|答案(1)|浏览(133)

使用带有调试环境的OpenGL 4.3,我能够标记程序、着色器、顶点数组和顶点缓冲区。
但是,我无法标记纹理,并在回调中收到以下错误:

Source: DebugSourceApi
Type: DebugTypeError
Id: 1011
Severity: DebugSeverityHigh
Message: glObjectLabel failed because (depending on the operation) a referenced binding point is empty; a referenced name is not the name of an object; or the given name is otherwise not valid to this operation (GL_INVALID_VALUE)

如果这很重要的话,我确实使用了OpenTK库。
以下是发生错误的代码块:

GL.GenTextures(1, out Texture);
const string labelTEX = "ImGui Texture";
GL.ObjectLabel(ObjectLabelIdentifier.Texture, Texture, labelTEX.Length, labelTEX);

问题:

为什么glObjectLabel对除GL_TEXTURE以外的所有东西都有效?

mv1qrgav

mv1qrgav1#

在您的示例代码中,您尚未创建纹理。你有created the name for a texture。为了创建实际的纹理对象,需要将此纹理名称绑定到上下文。
如果您的其他代码在为对象命名之前没有绑定该对象,那么您可能会逃脱惩罚,因为大多数对象都不是类型化的。纹理的特殊之处在于,为了创建它们,您必须为它们指定一个类型(glBindTexture中的第一个参数)。并且该类型成为纹理对象本身的一部分,指定在将来如何使用(和不使用)它。
或者,如果DSA functionality可用,只需切换到glCreate*函数并继续。

相关问题