PDA

View Full Version : Need to bind vertex attribute to location 0?



andras
10-06-2006, 10:24 PM
We only use custom vertex attributes, none of the built-in ones. We also use automatic binding of these attributes to vertex shader locations. Now, it seems like that on ATi, we have to bind at least one attribute to the 0th location, otherwise it won't render anything.

Is this a bug, or does the spec say somewhere that I have to use the 0th location?

Jackis
10-06-2006, 11:09 PM
It is not a bug, and it is also true on nVidia.
Nothing is rendered, if vertex attrib number 0 has no bindings.
OpenGL specification is still written in terms of Begin/End paradigm, which tells us, that it handles vertex only with glVertex() command (the same as glVertexAttrib(0, ...)), so you may potentially call lots of other attribute-setting commands (glTexCoord, glColor), but neither of them have sense, till you call glVertex().
So, I think, this is not a spec bug, but it is a desired behaviour.

dorbie
10-06-2006, 11:45 PM
Vertex position (attrib 0) is the invoking attribute.

This is not so clear when you use draw arrays but when you have the begin end rendering paradigm it is essential to have one attribute that says all the others are in place and to invoke the shading process.

OpenGL ES does not have begin end and only has drawarray* style calling and I think that spec fixes this but for desktop OpenGL we still have an invoking attribute. It is vestigial when you use draw arrays because all attributes explicitly exist at the time the draw call is invoked but I guess we still have to live with this for now.

It wouldn't surprise me if this actually worked on some implementations, but AFAIK if it works it is a bug, albeit a bug that makes a lot of sense.

andras
10-07-2006, 06:18 AM
It could be true on nVidia too, but at least they make sure that one of my attributes is bound to the 0th location.
Hopefully OpenGL LM will be out soon, and this behaviour will be gone :)