![]() | VertexAttribute Constructor (Program, Int32, String) |
Namespace: Ooogles
Exception | Condition |
---|---|
GLException | InvalidOperation if program is not a valid program. |
GLException | InvalidOperation if attributeName starts with the reserved prefix 'gl_'. |
GLException | InvalidValue if location is greater than or equal to the maximum number of supported vertex attributes. |
If attributeName refers to a matrix attribute variable, location refers to the first column of the matrix. Other matrix columns are then automatically bound to locations location+1 for a matrix of type Matrix2; location+1 and location+2 for a matrix of type Matrix3; and location+1, location+2, and location+3 for a matrix of type Matrix4.
This method makes it possible for vertex shaders to use descriptive names for attribute variables rather than generic numbered variables. The values sent to each generic attribute index are part of current state, just like standard vertex attributes such as color, normal, and vertex position. If a different program object is made current by calling Use, the generic vertex attributes are tracked in such a way that the same values will be observed by attributes in the new program object that are also bound to location.
Attribute bindings do not go into effect until Link is called. After a program object has been linked successfully, the index values for generic attributes remain fixed (and their values can be queried) until the next link command occurs.
Applications are not allowed to bind any of the standard OpenGL vertex attributes using this command, as they are bound automatically when needed. Any attribute binding that occurs after the program object has been linked will not take effect until the next time the program object is linked.
Note: this constructor can be called before any vertex shader objects are bound to the specified program object. It is also permissible to bind a generic attribute index to an attribute variable name that is never used in a vertex shader.
Note: if attributeName was bound previously, that information is lost. Thus you cannot bind one user-defined attribute variable to multiple indices, but you can bind multiple user-defined attribute variables to the same index.
Note: applications are allowed to bind more than one user-defined attribute variable to the same generic vertex attribute index. This is called aliasing, and it is allowed only if just one of the aliased attributes is active in the executable program, or if no path through the shader consumes more than one attribute of a set of attributes aliased to the same location. The compiler and linker are allowed to assume that no aliasing is done and are free to employ optimizations that work only in the absence of aliasing. OpenGL implementations are not required to do error checking to detect aliasing. Because there is no way to bind standard attributes, it is not possible to alias generic attributes with conventional ones (except for generic attribute 0).
Note: active attributes that are not explicitly bound will be bound by the linker when Link is called. The locations assigned can be queried by using the other constructor VertexAttribute(Program, String).
OpenGL API: glBindAttribLocation