Do you pass the normal to vertex index number 2 or do you fetch the vertex location with glGetAttribLocationARB(“gl_Normal”) and then pass the normal to that location?
is it suppose to work without having to do anything else?
It seems gl_Vertex contains valid values, but gl_Normal has a constant (wrong!) normal.
If I use glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer
it works as expected.
Can someone explain?[/b]
There is no aliasing between generic vertex attributes and fixed function attributes, except for gl_Vertex and generic attrib 0.
So using gl_Normal while enabling a vertex attrib is not a proper usage.
This is true for ARB_vertex_program as well, where aliasing is unspeficied.
If you want to use generic attributes, you will have to use a generic attribute in your shader, and get (or set) the attribute location in your C code.
Note as well that getting the location of gl_Normal should return -1, as it is a built in attribute, that you cannot load through generic attribute API.
so instead of using gl_Normal, use
attribute vec4 mynormal;
and then, do a
glGetAttribLocationARB(prog, “mynormal”);
Then you can enable/setup that vertex attribute.
so instead of using gl_Normal, use
attribute vec4 mynormal;
and then, do a
glGetAttribLocationARB(prog, “mynormal”);
The problem with this is you have to know ahead of time the name “mynormal”.
Besides, I though the standard attributes occupied specific slots, like for normal it is slot 2.
There is no aliasing between generic vertex attributes and fixed function attributes, except for gl_Vertex and generic attrib 0.
From my understanding, they had to do this because vertex or attrib0 is used for signaling, but I don’t see an explanation why gl_Normal and attrib2 can’t be the same?
glGetAttribLocationARB(handle, “gl_Normal”) is defined to return -1 for some unexplained reason.
Yes, I know about ARB_vertex_program.
It too defined normals as beeing mapped to attrib2 but there is no aliasing … weird
Originally posted by V-man:
[QB]The problem with this is you have to know ahead of time the name “mynormal”.
Besides, I though the standard attributes occupied specific slots, like for normal it is slot 2.
This is not the case. That is what I mean when I say there is no aliasing. the way the spec is written, slot 2 is a generic slot number 2, normal is a built-in slot. They do not end up being the same. In ARB_vertex_shader, you will see no table saying 2 is normal.
Originally posted by V-man:
[QB]
From my understanding, they had to do this because vertex or attrib0 is used for signaling, but I don’t see an explanation why gl_Normal and attrib2 can’t be the same?
Well, the spec says they are not.
From the spec:
There is no aliasing among generic attributes and conventional attributes. In other
words, an application can set all MAX_VERTEX_ATTRIBS_ARB generic attributes and all
conventional attributes without fear of one particular attribute overwriting the value
of another attribute.