OpenGL 中关于核心配置文件 330 上的顶点着色器和输入顶点的特殊行为

发布于 2024-09-16 18:33:39 字数 353 浏览 2 评论 0原文

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千柳 2024-09-23 18:33:40
  1. 如果您没有将属性绑定到位置,GL 会为您执行此操作。它使用哪些位置未指定,但您碰巧具有相同的值。

  2. 标准将这两个选项保留为开放状态,因为每个选项都有有效的用例。

  3. 对于弃用,nvidia 明确表示,他们认为弃用是错误的决定。最后,必须有人编写代码来发出警告……所以他们不发出警告也就不足为奇了,即使他们应该这样做。

  1. 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.

    • You can ask the GL which location it's chosen with glGetAttribLocation
    • Even though it's not specified, I've seen implementations choose to bind locations in order of the shader. First is 0, second is 1, ...
  2. The standard leaves those 2 options open because there are valid use cases for each.

  3. 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文