I can connect a VBO data with the shader's attribute using the followings functions:
GLint attribVertexPosition = glGetAttribLocation(progId, "vertexPosition");
glEnableVertexAttribArray(attribVertexPosition);
glVertexAttribPointer(attribVertexPosition, 3, GL_FLOAT, false, 0, 0);
I analyze a legacy OpenGL code where a VBO is used with the following functions:
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, 0);
How that legacy code makes a connnection between a VBO data and the shader's attribute:
attribute vec3 vertexPosition;
?
For these fixed-function functions, the binding between the buffer and the vertex attribute is fixed. You don't tell glVertexArray
which attribute it feeds; it always feeds the attribute gl_Vertex
, which is defined for you in the shader. It cannot feed any user-defined attribute.
User-defined attributes are a separate set of attributes from the fixed-functioned ones.
Note that NVIDIA hardware is known to violate this rule. It aliases certain attribute locations with certain built-in vertex arrays, which allows user-defined attributes to receive data from fixed-function arrays. Perhaps you are looking at code that relies on this non-standard behavior that is only available on NVIDIA's implementation.