【问题标题】:OpenGL: glVertexAttribFormat.attribindex vs GLSL vertex shader locationOpenGL:glVertexAttribFormat.attribindex 与 GLSL 顶点着色器位置
【发布时间】:2022-01-04 22:33:34
【问题描述】:

glVertexAttribFormat 中的attribindex 是否与我的 GLSL 顶点着色器中的布局位置相对应?

即如果我写

glVertexAttribFormat(0, 3, GL_FLOAT, GL_FALSE, offsetof(Vertex, position));

0 会与我的着色器中的这一行相对应吗?

layout (location = 0) in vec3 inPos;

【问题讨论】:

    标签: c++ opengl


    【解决方案1】:

    是的。否则如果没有location 说明符,您必须在程序链接后通过glGetAttribLocation() 查询属性位置,或者在通过glBindAttribLocation() 进行程序链接之前设置它。

    【讨论】:

    • 完美。我很确定是这样,但找不到任何明确说明的地方。
    猜你喜欢
    • 1970-01-01
    • 2011-08-31
    • 1970-01-01
    • 1970-01-01
    • 2017-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多