In OpenGL (specifically ES 2.0 in this case), what happens if I pass 2 components per vertex, like so:
glVertexAttribPointer( 0, 2, GL_FLOAT, GL_FALSE, sizeof( MyVertexStruct ), pPos );
…but the shader expects three?
It seems to default the third (Z, in this case) component to 0, which is what I want, but I’m hesitant to rely on the behavior. Is this defined somewhere in the OpenGL, ES, or GLSL standards?
(My search-fu is failing me: can’t find anything in the red book, purple book, or in the khronos.org reference pages, but I may have just overlooked it.)
Although I haven’t looked it up in the OpenGL specification, I’m pretty sure it is defined behaviour, that every attribute gets extended to (0,0,0,1) if it has fewer components, as it is also done this way when using the single attribute functions, like
glVertexAttrib2f(which is indeed specified by the standard).EDIT: I looked it up in the OpenGL ES 2.0 specification and it says:
So it is indeed like you and I assumed.