Click or drag to resize

VertexAttribute Constructor (Program, Int32, String)

Creates a vertex attribute by binding a user-defined attribute name to an attribute location.

Namespace:  Ooogles
Assembly:  Ooogles (in Ooogles.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public VertexAttribute(
	Program program,
	int location,
	string attributeName
)

Parameters

program
Type: OooglesProgram
the program containing the attribute.
location
Type: SystemInt32
the location of the attribute to be bound
attributeName
Type: SystemString
the (case-sensitive) name of the vertex shader attribute to which location is to be bound.
Exceptions
ExceptionCondition
GLExceptionInvalidOperation if program is not a valid program.
GLExceptionInvalidOperation if attributeName starts with the reserved prefix 'gl_'.
GLExceptionInvalidValue if location is greater than or equal to the maximum number of supported vertex attributes.
Remarks
This method is used to associate a user-defined attribute variable in the program object specified by program with a generic vertex attribute index. The name of the user-defined attribute variable is passed in attributeName. The generic vertex attribute index to be bound to this variable is specified by location. When program is made part of current state, values provided via the generic vertex attribute index will modify the value of the user-defined attribute variable specified by attributeName.

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

See Also