APi inconsistencies

Started by
0 comments, last by haegarr 11 years, 4 months ago

glEnableVertexAttribArray takes am attribute location value which you get with glGetAttribLocation. however, glGetAttribLocation returns a SIGNED integer, and

glEnableVertexAttribArray takes an UNsigned integer, as shown by ths following links (and this is how it is implemented in glew):


GLint glGetAttribLocation(GLuint program, const GLchar * name);
void glEnableVertexAttribArray(GLuint index);

http://www.opengl.org/sdk/docs/man/xhtml/glEnableVertexAttribArray.xml
http://www.opengl.org/sdk/docs/man/xhtml/glGetAttribLocation.xml

so I ask... "wtf?"

am I overlooking something important?

Advertisement
glGetAttribLocation uses a result of -1 to denote a problem. Cited from one of the links in the OP:

... If the named attribute variable is not an active attribute in the specified program object or if name starts with the reserved prefix "gl_", a value of -1 is returned.
-1 is noticeably different from the "valid" values, and it doesn't make sense to pass such an index into glEnableVertexAttribArray. Doing this requires a signed return type for glGetAttribLocation, but for the glEnableVertexAttribArray index an unsigned parameter type is still appropriate. (Whether this is a solution one is happy with is another question.)

This topic is closed to new replies.

Advertisement