OpenGL 中关于核心配置文件 330 上的顶点着色器和输入顶点的特殊行为
在 NVIDIA 上使用“#version 330 core”,
通过使用 glBindAttribLocation(program, 0, "in_Vertex");输入顶点与“in vec4 in_Vertex;”一起使用。但是,我注意到客户端应用程序中没有 OGL 函数调用,它仍然有效。它似乎是“默认的第一个输入变量”。为什么?应该省略它还是通过 glBindAttribLocation 显式连接到它? [根据标准,理想的是什么?] 还有“in vec4 gl_Vertex;”尽管规范称其已弃用并且着色器编译器不会给出任何警告,但它仍然有效。为什么?我本以为它至少会发出警告。我猜最后一个问题可能是编译器(GLSL 编译器)中的一个错误,但第一个问题尤其令人费解。
using '#version 330 core' on NVIDIA,
By using glBindAttribLocation(program, 0, "in_Vertex"); the input vertex works with an "in vec4 in_Vertex;". However, I noticed without the OGL function call in the client app, it still works. It appears to be 'the default first input variable'. Why? Should it be omitted or be explicitly connected to it via glBindAttribLocation? [What's the ideal according to the standard?] Also "in vec4 gl_Vertex;" works while the spec calls it deprecated and the compiler of shaders does not give any warning. Why? I would have expected for it to at least warn. I guess the last one may be a bug in the compiler (GLSL compiler) but the first issue is especially puzzling.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您没有将属性绑定到位置,GL 会为您执行此操作。它使用哪些位置未指定,但您碰巧具有相同的值。
询问 GL 选择哪个位置glGetAttribLocation
标准将这两个选项保留为开放状态,因为每个选项都有有效的用例。
对于弃用,nvidia 明确表示,他们认为弃用是错误的决定。最后,必须有人编写代码来发出警告……所以他们不发出警告也就不足为奇了,即使他们应该这样做。
if you don't bind attributes to a location, the GL will do it for you. Which locations it uses is unspecified but you happened to have the same value.
glGetAttribLocation
The standard leaves those 2 options open because there are valid use cases for each.
As for deprecation, nvidia clearly stated that they thing deprecation was the wrong decision. In the end somebody has to write the code to emit the warning... So it's not that surprising they would not warn, even if they ought to.