/// <summary>
 /// Construct an SubArrayBuffer from a <see cref="ArrayBufferItemAttribute"/>.
 /// </summary>
 /// <param name="arrayItemType">
 /// A <see cref="Type"/> describing the vertex array buffer item type.
 /// </param>
 public ArraySection(ArrayBufferObjectBase arrayBuffer, Type arrayItemType) :
     base(GetArrayType(arrayItemType))
 {
     if (arrayBuffer == null)
     {
         throw new ArgumentNullException("arrayBuffer");
     }
     _ArrayBuffer = arrayBuffer;
 }
            /// <summary>
            /// Construct an InstancedVertexArray for enabling instanced vertex attribute.
            /// </summary>
            /// <param name="arrayBuffer">
            /// A <see cref="ArrayBufferObjectBase"/> which defines a vertex array buffer.
            /// </param>
            /// <param name="sectionIndex">
            /// A <see cref="UInt32"/> that specify the section of <paramref name="arrayBuffer"/>.
            /// </param>
            /// <param name="divisor">
            /// A <see cref="UInt32"/> that specify the number of instances that will pass between updates of the generic attribute.
            /// </param>
            public InstancedVertexArray(ArrayBufferObjectBase arrayBuffer, uint sectionIndex, uint divisor) :
                base(arrayBuffer, sectionIndex)
            {
                if (divisor == 0)
                {
                    throw new ArgumentException("invalid value", "divisor");
                }

                Divisor = divisor;
            }
Ejemplo n.º 3
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="arrayBuffer"></param>
            /// <param name="sectionIndex"></param>
            public ArrayAttachment(ArrayBufferObjectBase arrayBuffer, uint sectionIndex)
            {
                if (arrayBuffer == null)
                {
                    throw new ArgumentNullException("arrayBuffer");
                }

                ArrayBuffer = arrayBuffer;
                ArrayBuffer.IncRef();
                ArraySectionIndex = sectionIndex;
            }
        /// <summary>
        /// Set an array buffer to a shader attribute.
        /// </summary>
        /// <param name="arrayBuffer">
        /// A <see cref="ArrayBufferObjectBase"/> that specify the contents of the array.
        /// </param>
        /// <param name="sectionIndex">
        /// A <see cref="UInt32"/> that specify the <paramref name="arrayBuffer"/> sub-array index.
        /// </param>
        /// <param name="attributeName">
        /// A <see cref="String"/> that specify the name of the attribute variable.
        /// </param>
        /// <param name="blockName">
        /// A <see cref="String"/> that specify the name of the attribute block encolosing <paramref name="semantic"/>. It
        /// can be null.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Exception thrown if <paramref name="arrayBuffer"/> is null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception throw if <paramref name="arrayBuffer"/> has no items.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="sectionIndex"/> specify an invalid section of <paramref name="arrayBuffer"/>.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="semantic"/> is null or is not a valid input name.
        /// </exception>
        public void SetArray(ArrayBufferObjectBase arrayBuffer, uint sectionIndex, string attributeName, string blockName)
        {
            if (String.IsNullOrEmpty(attributeName))
            {
                throw new ArgumentException("invalid name", "attributeName");
            }

            // Set vertex array
            SetVertexArray(new VertexArray(arrayBuffer, sectionIndex), attributeName, blockName);
            // Compute the actual vertex array length
            UpdateVertexArrayLength();
        }
        /// <summary>
        /// Link an array buffer to an attribute of this vertex array.
        /// </summary>
        /// <param name="arrayBuffer">
        /// A <see cref="ArrayBufferObjectBase"/> that specify the contents of the array.
        /// </param>
        /// <param name="sectionIndex">
        /// A <see cref="UInt32"/> that specify the <paramref name="arrayBuffer"/> sub-array index.
        /// </param>
        /// <param name="attributeName">
        /// A <see cref="String"/> that specify the name of the attribute variable.
        /// </param>
        /// <param name="blockName">
        /// A <see cref="String"/> that specify the name of the attribute block encolosing <paramref name="semantic"/>. It
        /// can be null.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Exception thrown if <paramref name="arrayBuffer"/> is null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception throw if <paramref name="arrayBuffer"/> has no items.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="sectionIndex"/> specify an invalid section of <paramref name="arrayBuffer"/>.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="semantic"/> is null or is not a valid input name.
        /// </exception>
        public void SetInstancedArray(ArrayBufferObjectBase arrayBuffer, uint sectionIndex, uint divisor, string attributeName, string blockName)
        {
            if (GraphicsContext.CurrentCaps.GlExtensions.InstancedArrays == false)
            {
                throw new InvalidOperationException("instanced arrays not support by current implementation");
            }
            if (String.IsNullOrEmpty(attributeName))
            {
                throw new ArgumentException("invalid name", "attributeName");
            }

            // Set vertex array
            SetVertexArray(new InstancedVertexArray(arrayBuffer, sectionIndex, divisor), attributeName, blockName);
            // Note: instanced vertex arrays do not contribute to vertex array length. Do not update vertex arrays length
        }
Ejemplo n.º 6
0
            /// <summary>
            /// Construct an VertexArray for enabling vertex attribute.
            /// </summary>
            /// <param name="arrayBuffer">
            /// A <see cref="ArrayBufferObjectBase"/> which defines a vertex array buffer.
            /// </param>
            /// <param name="sectionIndex">
            /// A <see cref="UInt32"/> that specify the section of <paramref name="arrayBuffer"/>.
            /// </param>
            public VertexArray(ArrayBufferObjectBase arrayBuffer, uint sectionIndex)
            {
                if (arrayBuffer != null && arrayBuffer.ItemCount == 0)
                {
                    throw new ArgumentException("zero items", "arrayBuffer");
                }
                if (arrayBuffer != null && sectionIndex >= arrayBuffer.ArraySectionsCount)
                {
                    throw new ArgumentOutOfRangeException("out of bounds", "sectionIndex");
                }

                ArrayBuffer = arrayBuffer;
                if (ArrayBuffer != null)
                {
                    ArrayBuffer.IncRef();
                }
                ArraySectionIndex = sectionIndex;
            }
Ejemplo n.º 7
0
        /// <summary>
        /// Link an array buffer to an attribute of this vertex array.
        /// </summary>
        /// <param name="arrayBuffer">
        /// A <see cref="ArrayBufferObjectBase"/> that specify the contents of the array.
        /// </param>
        /// <param name="sectionIndex">
        /// A <see cref="UInt32"/> that specify the <paramref name="arrayBuffer"/> sub-array index.
        /// </param>
        /// <param name="attributeName">
        /// A <see cref="String"/> that specify the name of the attribute variable.
        /// </param>
        /// <param name="blockName">
        /// A <see cref="String"/> that specify the name of the attribute block encolosing <paramref name="semantic"/>. It
        /// can be null.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Exception thrown if <paramref name="arrayBuffer"/> is null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception throw if <paramref name="arrayBuffer"/> has no items.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="sectionIndex"/> specify an invalid section of <paramref name="arrayBuffer"/>.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Exception thrown if <paramref name="semantic"/> is null or is not a valid input name.
        /// </exception>
        public void SetArray(ArrayBufferObjectBase arrayBuffer, uint sectionIndex, string attributeName, string blockName)
        {
            if (String.IsNullOrEmpty(attributeName))
            {
                throw new ArgumentException("invalid name", "attributeName");
            }

            VertexArray vertexArray, previousVertexArray;

            // Dispose previous vertex array
            if (_VertexArrays.TryGetValue(attributeName, out previousVertexArray))
            {
                previousVertexArray.Dispose();
            }
            // Map buffer object with attribute name
            _VertexArrays[attributeName] = vertexArray = new VertexArray(arrayBuffer, sectionIndex);

            // Map buffer object with input name including block name also
            if (blockName != null)
            {
                // Attribute referenced in block
                attributeName = String.Format("{0}.{1}", blockName, attributeName);

                // Dispose previous vertex array
                if (_VertexArrays.TryGetValue(attributeName, out previousVertexArray))
                {
                    previousVertexArray.Dispose();
                }
                // Map buffer object with attribute name
                _VertexArrays[attributeName] = vertexArray;
            }

            // Compute the actual vertex array length
            UpdateVertexArrayLength();
            // Update vertex arrays
            _VertexArrayDirty = true;
        }
Ejemplo n.º 8
0
 public void AttachArray(uint varyingLocation, ArrayBufferObjectBase arrayBuffer, uint sectionIndex)
 {
     _AttachedArrays[varyingLocation] = new ArrayAttachment(arrayBuffer, sectionIndex);
 }
Ejemplo n.º 9
0
 public void AttachArray(uint varyingLocation, ArrayBufferObjectBase arrayBuffer)
 {
     AttachArray(varyingLocation, arrayBuffer, 0);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Set an array buffer to this vertex array.
 /// </summary>
 /// <param name="arrayBuffer">
 /// A <see cref="ArrayBufferObjectBase"/> that specify the contents of the array.
 /// </param>
 /// <param name="semantic">
 /// A <see cref="String"/> that specify the attribute semantic. Normally a constant of <see cref="VertexArraySemantic"/>.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// Exception thrown if <paramref name="arrayBuffer"/> is null.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// Exception throw if <paramref name="arrayBuffer"/> has no items.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// Exception thrown if <paramref name="semantic"/> is null or is not a valid semantic name.
 /// </exception>
 public void SetArray(ArrayBufferObjectBase arrayBuffer, string semantic)
 {
     SetArray(arrayBuffer, 0, semantic, SemanticBlockName);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Set an array buffer to this vertex array.
 /// </summary>
 /// <param name="arrayBuffer">
 /// A <see cref="ArrayBufferObjectBase"/> that specify the contents of the array.
 /// </param>
 /// <param name="sectionIndex">
 /// A <see cref="UInt32"/> that specify the <paramref name="arrayBuffer"/> sub-array index.
 /// </param>
 /// <param name="semantic">
 /// A <see cref="String"/> that specify the attribute semantic. Normally a constant of <see cref="VertexArraySemantic"/>.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// Exception thrown if <paramref name="arrayBuffer"/> is null.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// Exception throw if <paramref name="arrayBuffer"/> has no items.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// Exception thrown if <paramref name="sectionIndex"/> specify an invalid section of <paramref name="arrayBuffer"/>.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// Exception thrown if <paramref name="semantic"/> is null or is not a valid semantic name.
 /// </exception>
 public void SetArray(ArrayBufferObjectBase arrayBuffer, uint sectionIndex, string semantic)
 {
     SetArray(arrayBuffer, sectionIndex, semantic, SemanticBlockName);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Set an array buffer to this vertex array.
 /// </summary>
 /// <param name="arrayBuffer">
 /// A <see cref="ArrayBufferObjectBase"/> that specify the contents of the array.
 /// </param>
 /// <param name="sectionIndex">
 /// A <see cref="UInt32"/> that specify the <paramref name="arrayBuffer"/> sub-array index.
 /// </param>
 /// <param name="inputName">
 /// A <see cref="String"/> that specify the name of the input variable.
 /// </param>
 /// <param name="blockName">
 /// A <see cref="String"/> that specify the name of the input block encolosing <paramref name="inputName"/>. It
 /// can be null.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// Exception thrown if <paramref name="arrayBuffer"/> is null.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// Exception throw if <paramref name="arrayBuffer"/> has no items.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// Exception thrown if <paramref name="inputName"/> is null or is not a valid input name.
 /// </exception>
 public void SetArray(ArrayBufferObjectBase arrayBuffer, string inputName, string blockName)
 {
     SetArray(arrayBuffer, 0, inputName, blockName);
 }
 /// <summary>
 /// Set an array buffer to this vertex array.
 /// </summary>
 /// <param name="arrayBuffer">
 /// A <see cref="ArrayBufferObjectBase"/> that specify the contents of the array.
 /// </param>
 /// <param name="semantic">
 /// A <see cref="String"/> that specify the attribute semantic. Normally a constant of <see cref="VertexArraySemantic"/>.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// Exception thrown if <paramref name="arrayBuffer"/> is null.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// Exception throw if <paramref name="arrayBuffer"/> has no items.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// Exception thrown if <paramref name="semantic"/> is null or is not a valid semantic name.
 /// </exception>
 public void SetInstancedArray(ArrayBufferObjectBase arrayBuffer, uint divisor, string semantic)
 {
     SetInstancedArray(arrayBuffer, 0, divisor, semantic, SemanticBlockName);
 }
 /// <summary>
 /// Set an array buffer to this vertex array.
 /// </summary>
 /// <param name="arrayBuffer">
 /// A <see cref="ArrayBufferObjectBase"/> that specify the contents of the array.
 /// </param>
 /// <param name="sectionIndex">
 /// A <see cref="UInt32"/> that specify the <paramref name="arrayBuffer"/> sub-array index.
 /// </param>
 /// <param name="inputName">
 /// A <see cref="String"/> that specify the name of the input variable.
 /// </param>
 /// <param name="blockName">
 /// A <see cref="String"/> that specify the name of the input block encolosing <paramref name="inputName"/>. It
 /// can be null.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// Exception thrown if <paramref name="arrayBuffer"/> is null.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// Exception throw if <paramref name="arrayBuffer"/> has no items.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// Exception thrown if <paramref name="inputName"/> is null or is not a valid input name.
 /// </exception>
 public void SetInstancedArray(ArrayBufferObjectBase arrayBuffer, uint divisor, string inputName, string blockName)
 {
     SetInstancedArray(arrayBuffer, 0, divisor, inputName, blockName);
 }