Adds an attribute to a buffer, or replaces a previously added attribute with the same name.
Use the CoglPrimitive api instead
You either can use one of the built-in names such as "gl_Vertex", or "gl_MultiTexCoord0" to add standard attributes, like positions, colors and normals, or you can add custom attributes for use in shaders.
The number of vertices declared when calling VertexBuffer
determines how many attribute values will be read from the supplied pointer.
The data for your attribute isn't copied anywhere until you call submit, or issue a draw call which automatically submits pending attribute changes. so the supplied pointer must remain valid until then. If you are updating an existing attribute (done by re-adding it) then you still need to re-call submit to commit the changes to the GPU. Be carefull to minimize the number of calls to submit, though.
<note>If you are interleving attributes it is assumed that each interleaved attribute starts no farther than +- stride bytes from the other attributes it is interleved with. I.e. this is ok: <programlisting> |-0-0-0-0-0-0-0-0-0-0| </programlisting> This is not ok: <programlisting> |- - - - -0-0-0-0-0-0 0 0 0 0| </programlisting> (Though you can have multiple groups of interleved attributes)</note>
| attribute_name |
The name of your attribute. It should be a valid GLSL variable name and standard attribute types must use one of following
built-in names: (Note: they correspond to the built-in names of GLSL) <itemizedlist> <listitem>"gl_Color"</listitem
> <listitem>"gl_Normal"</listitem> <listitem>"gl_MultiTexCoord0, gl_MultiTexCoord1, ..."</listitem>
<listitem>"gl_Vertex"</listitem> </itemizedlist> To support adding multiple variations of the same attribute the
name can have a detail component, E.g. "gl_Color: |
| n_components |
The number of components per attribute and must be 1, 2, 3 or 4 |
| type |
a AttributeType specifying the data type of each component. |
| normalized |
If true, this specifies that values stored in an integer format should be mapped into the range [-1.0, 1.0] or [0.0, 1.0] for unsigned values. If false they are converted to floats directly. |
| stride |
This specifies the number of bytes from the start of one attribute value to the start of the next value (for the same attribute). So, for example, with a position interleved with color like this: XYRGBAXYRGBAXYRGBA, then if each letter represents a byte, the stride for both attributes is 6. The special value 0 means the values are stored sequentially in memory. |
| pointer |
This addresses the first attribute in the vertex array. This must remain valid until you either call submit or issue a draw call. |
| handle |
A vertex buffer handle |