When reading the specs I understood that a mat4x4 vertex attribute needs 4 attribute locations:
glspec32.core.20090803.pdf (page 52):
When an attribute variable is declared as a mat2x4, mat3x4 or mat4, its matrix columns are taken from the (x; y; z; w) components of generic attributes i and i+1 (mat2x4), from attributes i through i + 2 (mat3x4), or from attributes i through i + 3 (mat4).
However, when using the vertex shader below and (after linking) querying the active attributes, and requesting their names one by one, it seems like the mat4x4 attributes take only one attribute location. Did I misinterpret the specs? Or is it a bug in the OpenGL driver (AMD 9.10 Linux driver). Perhaps the spec is wrong? (I couldn’t find a similar phrase for the active uniforms, but I could have overlooked it).
When using `in vec4 arrayOfvalues[4]', it uses four attribute locations (as expected).
// vertex shader
precision highp float;
in int material;
in mat4x4 vertex;
in mat4x4 normal;
in mat4x4 colour;
uniform mat4x4 nor_matrix;
uniform mat4x4 mvp_matrix;
smooth out vec4 ocolour;
smooth out vec4 onormal;
flat out int omaterial;
void main(void)
{
ocolour = vec4(1.1, 1.2, 1.3, 1.4) * colour;
onormal = vec4(1.1, 1.2, 1.3, 1.4) * nor_matrix * normal;
omaterial = material;
gl_Position = vec4(1.1, 1.2, 1.3, 1.4) * mvp_matrix * vertex;
}
// for completeness sake, the accompanying fragment shader
#version 140
precision highp float;
smooth in vec4 ocolour;
smooth in vec4 onormal;
flat in int omaterial;
out vec4 fragcolour;
void main(void)" << endl
{
fragcolour = onormal;
};
Output of querying the active attributes and uniforms:
active_attributes: 4
active_attributes_max_length: 9
active_uniforms: 2
active_uniform_max_length: 11
// name - index - size - type (obtained with glGetActiveAttrib)
`colour': 0 (size: 1, 35676)
`material': 1 (size: 1, 5124)
`normal': 2 (size: 1, 35676)
`vertex': 3 (size: 1, 35676)
// name - index - size - type (obtained with glGetActiveUniform)
`mvp_matrix': 0 (size: 1, 35676)
`nor_matrix': 1 (size: 1, 35676)
Can anybody provide some insight in what is going on?