Skip to main content
GameDev.net gamedev.net
🔒 Locked

APi inconsistencies

Started by caibbor Dec 30, 2012 at 9:53 AM 0 replies 2.1k views
Original Post
caibbor
caibbor

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?

haegarr
haegarr
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.)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.