Besides the required vertex position, vertices can have several other numeric attributes. Each is specified in the format string with a letter, the number of components and the data type.
Each of the attributes is described in the table below with the set of valid format strings written as a regular expression (for example, "v[234][if]" means "v2f", "v3i", "v4f", etc. are all valid formats).
Some attributes have a "recommended" format string, which is the most efficient form for the video driver as it requires less conversion.
Attribute Formats Recommended Vertex position "v[234][sifd]" "v[234]f" Color "c[34][bBsSiIfd]" "c[34]B" Edge flag "e1[bB]" Fog coordinate "f[1234][bBsSiIfd]" Normal "n3[bsifd]" "n3f" Secondary color "s[34][bBsSiIfd]" "s[34]B" Texture coordinate "t[234][sifd]" "t[234]f" Generic attribute "[0-15]g(n)?[1234][bBsSiIfd]"
The possible data types that can be specified in the format string are described below.
Format Type Python type "b" Signed byte int "B" Unsigned byte int "s" Signed short int "S" Unsigned short int "i" Signed int int "I" Unsigned int int "f" Single precision float float "d" Double precision float float
The following attributes are normalised to the range [0, 1]. The value is used as-is if the data type is floating-point. If the data type is byte, short or int, the value is divided by the maximum value representable by that type. For example, unsigned bytes are divided by 255 to get the normalised value.
Up to 16 generic attributes can be specified per vertex, and can be used by shader programs for any purpose (they are ignored in the fixed-function pipeline). For the other attributes, consult the OpenGL programming guide for details on their effects.
When using the pyglet.graphics.draw and related functions, attribute data is specified alongside the vertex position data. The following example reproduces the two points from the previous page, except that the first point is blue and the second green:
pyglet.graphics.draw(2, pyglet.gl.GL_POINTS, ('v2i', (10, 15, 30, 35)), ('c3B', (0, 0, 255, 0, 255, 0)) )
It is an error to provide more than one set of data for any attribute, or to mismatch the size of the initial data with the number of vertices specified in the first argument.