/// <summary> /// Creates a <see cref="VertexAttribute"/> array from a list of attribute templates. /// Offset and stride are calculated automatically, assuming zero padding. /// </summary> /// <param name="attributes">The attribute templates.</param> public static VertexAttribute[] MakeAttributeArray(IList <IAttributeTemplate> attributes) { var stride = attributes.Sum(a => a.Bytes); var array = new VertexAttribute[attributes.Count]; var offset = 0; for (int i = 0; i < attributes.Count; i++) { var template = attributes[i]; array[i] = template.ToAttribute(offset, stride); offset += template.Bytes; } return(array); }
/// <summary> /// Sets the vertex attributes. /// </summary> /// <param name="vertexAttributes">The vertex attributes to set.</param> public void SetVertexAttributes(VertexAttribute[] vertexAttributes) { for (int i = 0; i < vertexAttributes.Length; i++) vertexAttributes[i].setAttribute(this); }