OpenGL:glVertexAttribFormat.attribindex 对比 GLSL 顶点着色器位置

OpenGL: glVertexAttribFormat.attribindex vs GLSL vertex shader location

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

即如果我写

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

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

layout (location = 0) in vec3 inPos;

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

设置它