add


Description:

public void add (string attribute_name, uchar n_components, AttributeType type, bool normalized, uint16 stride, void* pointer)

Adds an attribute to a buffer, or replaces a previously added attribute with the same name.

Note:

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:

|-0-0-0-0-0-0-0-0-0-0|

This is not ok:

|- - - - -0-0-0-0-0-0 0 0 0 0|

(Though you can have multiple groups of interleved attributes)

Parameters:

attribute_name

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




2022 vala-language.org