glVertexAttribPointer and gl_Normal
I'm trying to pass some normals to a shader written in GLSL using glVertexAttribPointer but I can't seem to get it working. I read that vertex positions should be at index 0 and normals at 2.
It works fine with vertex positions.
glVertexAttribPointer(0, 3, GL_FLOAT, ...)
But it doesn't work when I try to use it with my vertex normals.
glVertexAttribPointer(2, 3, GL_FLOAT, ...)
If I just use the deprecated glNormalPointer gl_Normal is populated with my normals in the shader as it should. Likewise if I bind index 2 to a custom value called in_Normal that variable is filled with the expected value.
Therefore it can't be something with my normal array.
Thanks in advance.
Quote:Original post by nekx
Likewise if I bind index 2 to a custom value called in_Normal that variable is filled with the expected value.
This is correct way how to use glVertexAttribPointer.
GL driver can assign any attribute index to vertex attribute.
Thanks for your answers.
Is there any way I can use glVertexAttribPointer to fill the gl_Normal value? Using a custom variable like in_Normal works but I'd like to just use the standard variable.
Is there any way I can use glVertexAttribPointer to fill the gl_Normal value? Using a custom variable like in_Normal works but I'd like to just use the standard variable.
Same here. Is it possible to treat built in attributes like generic ones? means can I fill built in attributes like normals/colors etc. withglVertexAttribPointer ?
cheers,
dave
cheers,
dave
Quote:
Is there any way I can use glVertexAttribPointer to fill the gl_Normal value? Using a custom variable like in_Normal works but I'd like to just use the standard variable.
I'm not sure if this is technically possible, but gl_Normal is not really "the standard variable" anymore, its depreciated and as such you've got no reason to use it.
As bubu said, the proper and forward-looking technique is to define your own variables for all attributes.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement