cmk
10-27-2007, 02:05 PM
The system:
Win XP x64
nVidia 7800 GTX w/ Forceware 162.18 drivers
I was building a shader framework and found the following:
1.
If a vertex shader doesn't use gl_Vertex either directly, or indirectly via ftransform(), then the first user attribute will be bound to slot 0.
The result is that glGetAttribLocation(my_attrib) returns 0, and using 0 in glGetVertexAttrib*() or glVertexAttrib*() returns an error - GL_INVALID_VALUE.
This means i can't get/set the user attrib if it happens to be the one bound to 0.
Granted, there are few cases where gl_Vertex or ftransform() aren't used, but still.
Which is wrong, the linker auto-binding a user attribute to 0, or glGetVertexAttrib*()/glVertexAttrib*() returning an error when passed auto-bound location = 0. I believe the former.
2.
glGetActiveAttrib returns the vector type for matrix attributes.
e.g.
in shader have "attribute mat4 my_mat;"
glGetActiveAttrib("my_mat") returns:
type = GL_FLOAT_VEC4
size = 1
It does however reserve 4 index slots.
I was expecting type = GL_FLOAT_VEC4, size = 4, but would have settled for type = GL_FLOAT_MAT4, size = 1.
Can anyone verify this, or have i misunderstood something.
Win XP x64
nVidia 7800 GTX w/ Forceware 162.18 drivers
I was building a shader framework and found the following:
1.
If a vertex shader doesn't use gl_Vertex either directly, or indirectly via ftransform(), then the first user attribute will be bound to slot 0.
The result is that glGetAttribLocation(my_attrib) returns 0, and using 0 in glGetVertexAttrib*() or glVertexAttrib*() returns an error - GL_INVALID_VALUE.
This means i can't get/set the user attrib if it happens to be the one bound to 0.
Granted, there are few cases where gl_Vertex or ftransform() aren't used, but still.
Which is wrong, the linker auto-binding a user attribute to 0, or glGetVertexAttrib*()/glVertexAttrib*() returning an error when passed auto-bound location = 0. I believe the former.
2.
glGetActiveAttrib returns the vector type for matrix attributes.
e.g.
in shader have "attribute mat4 my_mat;"
glGetActiveAttrib("my_mat") returns:
type = GL_FLOAT_VEC4
size = 1
It does however reserve 4 index slots.
I was expecting type = GL_FLOAT_VEC4, size = 4, but would have settled for type = GL_FLOAT_MAT4, size = 1.
Can anyone verify this, or have i misunderstood something.