glVertexAttrib() without glBegin()/glEnd()?

Just a quick question: I know that glBegin() and glEnd() have been dropped from recent versions of the spec, but I noticed today that glVertexAttrib() is still there. How is the latter intended to be used without the former?

Thanks,

  • cort

glVertexAttrib sets an attribute on the “current” vertex.

If the vertex array for an attribute input to a shader is not enabled, then the shader still needs some input. That input comes from the “current” vertex-- e.g. the same value is replicated for every vertex.

Okay, thanks! I suspected that might be the case, but I figured at that point you could just use a uniform variable.

  • cort

It’s useful for reusing a shader with a model that has an attribute that is constant. With glVertexAttrib(), you don’t need to write another shader for that case, if you already have one written for the varying attribute case.