예제 #1
0
        /// <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);
        }
예제 #2
0
 /// <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);
 }