我正在調查OpenGL Android deqp測試套裝並與其中一個案例混淆。測試是dEQP-GLES31.functional.vertex_attribute_binding.usage.mixed_usage.mixed_api_change_binding_point。 可以找到來源here,感興趣的線是1197-1213。我不知道,這是一個竅門。ARB_vertex_attrib_binding測試案例瞭解
const int maxUsedLocation = de::max(positionLoc, colorLoc);
const int bindingPoint1 = maxUsedLocation + 1;
const int bindingPoint2 = maxUsedLocation + 2;
// bind data using old api
gl.glBindBuffer(GL_ARRAY_BUFFER, m_buffer);
gl.glVertexAttribPointer(bindingPoint1, 4, GL_FLOAT, GL_FALSE, (glw::GLsizei)(2 * sizeof(tcu::Vec4)), (const deUint8*)DE_NULL);
gl.glVertexAttribPointer(bindingPoint2, 4, GL_FLOAT, GL_FALSE, (glw::GLsizei)(2 * sizeof(tcu::Vec4)), (const deUint8*)DE_NULL + sizeof(tcu::Vec4));
// change buffer binding point with vertex_attrib_binding
gl.glVertexAttribFormat(positionLoc, 4, GL_FLOAT, GL_FALSE, 0);
gl.glVertexAttribFormat(colorLoc, 4, GL_FLOAT, GL_FALSE, 0);
gl.glVertexAttribBinding(positionLoc, bindingPoint1);
gl.glVertexAttribBinding(colorLoc, bindingPoint2);
首先,bindingPoint1
和bindingPoint2
以一種奇怪的方式(在着色器最大數量的頂點位置的增量)被初始化。然後它被用作glVertexAttribPointer
中的頂點屬性位置(?)。之後,它用作glVertexAttribBinding
中的頂點緩衝區綁定點。最後,沒有glBindVertexBuffer
調用,哪個緩衝區bindingPoint1
和bindingPoint2
被綁定?我試圖瞭解ARB_vertex_attrib_binding擴展,但我仍然不明白這段代碼。
對我來說,似乎glVertexAttribPointer
是不正確的,因爲不正確的頂點attrib位置和glVertexAttribBinding
是不正確的,因爲沒有頂點綁定點綁定到頂點緩衝區。 有人可以解釋我,這是怎麼回事?