Hi all,
Recently I had a discussion concerning the behaviour of the GL when binding vertex attribute data to variables in a shader.
Let’s look at this situation:
// A simple interleaved vertex format x, y, z, s, t
float l_Vertices[] =
{
0., 0, 0., 0., 0.,
1., 0, 0., 1., 0.,
1., 1, 0., 1., 1.,
0., 1, 0., 0., 1.
}
(m_Pos was bound to location 0, m_TexCoord was bound to location 1)
// Set the data
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5sizeof(float), l_Vertices);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5sizeof(float), &l_Vertices[3]);
Now what happens if in the shader the m_Pos attribute variable is declare as:
attribute vec4 m_Pos;
attribute vec2 m_TexCoord;
If the mismatch in component count of the shader variable and the pointer assignment guaranteed to be valid?
And would the m_Pos.w component guaranteed to be set to 1.0?
Any thoughts anyone?
Cheers