glGetAttribLocation

Returns the location of an attribute variable

Signature

glGetAttribLocation( GLuint ( program ) , const GLchar *( name ) )-> GLint
glGetAttribLocation( program , name ) -> <class 'ctypes.c_int'>
Check that name is a string with a null byte at the end of it

Parameters

VariablesDescription
program
Specifies the program object to be queried.
name
Points to a null terminated string containing the name of the attribute variable whose location is to be queried.

Description

glGetAttribLocation queries the previously linked program object specified by program for the attribute variable specified by name and returns the index of the generic vertex attribute that is bound to that attribute variable. If name is a matrix attribute variable, the index of the first column of the matrix is returned. 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.
The association between an attribute variable name and a generic attribute index can be specified at any time by calling glBindAttribLocation . Attribute bindings do not go into effect until glLinkProgram is called. After a program object has been linked successfully, the index values for attribute variables remain fixed until the next link command occurs. The attribute values can only be queried after a link if the link was successful. glGetAttribLocation returns the binding that actually went into effect the last time glLinkProgram was called for the specified program object. Attribute bindings that have been specified since the last link operation are not returned by glGetAttribLocation .

Errors

GL_INVALID_OPERATION is generated if program is not a value generated by OpenGL.
GL_INVALID_OPERATION is generated if program is not a program object.
GL_INVALID_OPERATION is generated if program has not been successfully linked.

Associated Gets

glGetActiveAttrib with argument program and the index of an active attribute

Version Support

glGetAttribLocation

See Also

Copyright

Copyright
2003-2005 3Dlabs Inc. Ltd. Copyright
2010-2014 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. .

Sample Code References

The following code samples have been found which appear to reference the functions described here. Take care that the code may be old, broken or not even use PyOpenGL.

glGetAttribLocation
OpenGLContext OpenGLContext/scenegraph/shaders.py Lines: 565
OpenGLContext tests/shader_6.py Lines: 229
OpenGLContext tests/pygame_textureatlas.py Lines: 69, 70
OpenGLContext tests/shader_4.py Lines: 95, 98, 101
OpenGLContext tests/shader_11.py Lines: 232
OpenGLContext tests/shader_7.py Lines: 236
OpenGLContext tests/shader_5.py Lines: 279
OpenGLContext tests/shader_9.py Lines: 304
OpenGLContext tests/shader_10.py Lines: 240
OpenGLContext tests/shader_8.py Lines: 181
OpenGLContext tests/shader_spike.py Lines: 13, 66, 69
Gloopy gloopy/view/shader.py Lines: 29