Instance Method


Sets the offset for each vertex attribute to the minimum value to pack vertex data together in a single buffer.


- (void)setPackedOffsets;


This method examines the stride property of each of the descriptor’s vertex buffer layouts, calculates an offset for each of the descriptor’s vertex attributes that fits vertex data into a single buffer with minimal unused padding space between attributes, then sets the offset property of each vertex attribute to the calculated value.

For example, consider a vertex buffer with three attributes: position, normal, and texture coordinates. The position and normal attributes each contain 3-component floating-point vectors for each vertex, and the texture coordinate attribute contains a 2-component floating-point vector for each vertex. The default stride for the each of the first two attributes is 12 bytes (4 bytes per component), and the default stride for the third is 8 bytes (4 bytes per component). Therefore, to pack data for the attributes together in the same vertex buffer, the offest for the position attribute is 0, the offset for the normal attribute is 12 (the width of the first attribute), and the offset of the texture coordinate attribute is 24 (the combined width of the first two attributes).

To describe a fully packed vertex buffer, call this method before calling the setPackedStrides method.

See Also

Working with Vertex Attributes


The list of vertex attributes described by the vertex descriptor.

- attributeNamed:

Returns the vertex attribute with the specified name in the vertex descriptor.

- addOrReplaceAttribute:

Adds the specified vertex attribute to the vertex descriptor, replacing any existing attribute with the same name.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software