JavaScript EditorFree JavaScript Editor     Ajax Editor 



Main Page
Previous Page
Next Page

glGetActiveAttrib

Name

glGetActiveAttrib Returns information about an active attribute variable for the specified program object

C Specification

void glGetActiveAttrib(GLuint program,
                       GLuint index,
                       GLsizei bufSize,
                       GLsizei *length,
                       GLint *size,
                       GLenum *type,
                       GLchar *name)

Parameters

program

Specifies the program object to be queried.

index

Specifies the index of the attribute variable to be queried.

bufSize

Specifies the maximum number of characters OpenGL is allowed to write in the character buffer indicated by name.

length

Returns the number of characters actually written by OpenGL in the string indicated by name (excluding the null terminator) if a value other than NULL is passed.

size

Returns the size of the attribute variable.

type

Returns the data type of the attribute variable.

name

Returns a null terminated string containing the name of the attribute variable.


Description

glGetActiveAttrib returns information about an active attribute variable in the program object specified by program. The number of active attributes can be obtained by calling glGetProgram with the value GL_ACTIVE_ATTRIBUTES. A value of 0 for index selects the first active attribute variable. Permissible values for index range from 0 to the number of active attribute variables minus 1.

A vertex shader may use built-in attribute variables, user-defined attribute variables, or both. Built-in attribute variables have a prefix of "gl_" and reference conventional OpenGL vertex attributes (e.g., gl_Vertex, gl_Normal; see the OpenGL Shading Language specification for a complete list.) Userdefined attribute variables have arbitrary names and obtain their values through numbered generic vertex attributes. An attribute variable (either built-in or user-defined) is considered active if during the link operation, the determination is made that the attribute variable can be accessed during program execution. Therefore, program should have previously been the target of a call to glLinkProgram, but it is not necessary for it to have been linked successfully.

The size of the character buffer required to store the longest attribute variable name in program can be obtained by calling glGetProgram with the value GL_ACTIVE_ATTRIBUTE_MAX_LENGTH. This value should be used to allocate a buffer of sufficient size to store the returned attribute name. The size of this character buffer is passed in bufSize, and a pointer to this character buffer is passed in name.

glGetActiveAttrib returns the name of the attribute variable indicated by index, storing it in the character buffer specified by name. The string returned is null terminated. The actual number of characters written into this buffer is returned in length, and this count does not include the null termination character. If the length of the returned string is not required, a value of NULL can be passed in the length argument.

The type argument returns a pointer to the attribute variable's data type. The symbolic constants GL_FLOAT, GL_FLOAT_VEC2, GL_FLOAT_VEC3, GL_FLOAT_VEC4, GL_FLOAT_MAT2, GL_FLOAT_MAT3, GL_FLOAT_MAT4 may be returned. The size argument returns the size of the attribute, in units of the type returned in type.

The list of active attribute variables may include both built-in attribute variables (which begin with the prefix "gl_") as well as user-defined attribute variable names.

This function returns as much information as it can about the specified active attribute variable. If no information is available, length is 0, and name is an empty string. This situation could occur if this function is called after a link operation that failed. If an error occurs, the return values length, size, type, and name are unmodified.

Notes

glGetActiveAttrib is available only if the GL version is 2.0 or greater.

Errors

GL_INVALID_VALUE 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_VALUE is generated if index is greater than or equal to the number of active attribute variables in program.

GL_INVALID_OPERATION is generated if glGetActiveAttrib is executed between the execution of glBegin and the corresponding execution of glEnd.

GL_INVALID_VALUE is generated if bufSize is less than 0.

Associated Gets

glGet with argument GL_MAX_VERTEX_ATTRIBS

glGetProgram with argument GL_ACTIVE_ATTRIBUTES or GL_ACTIVE_ATTRIBUTE_MAX_LENGTH

glIsProgram

See Also

glBindAttribLocation, glLinkProgram, glVertexAttrib, glVertexAttribPointer


Previous Page
Next Page




JavaScript EditorAjax Editor     JavaScript Editor