コード例 #1
0
        /// <summary>
        /// Get an element from this mapped BufferObject.
        /// </summary>
        /// <typeparam name="T">
        /// A structure representing this BufferObject element.
        /// </typeparam>
        /// <param name="index">
        /// A <see cref="uint"/> that specify the index of the element to get.
        /// </param>
        /// <param name="sectionIndex">
        /// A <see cref="uint"/> that specifies the array section index for supporting packed/interleaved arrays.
        /// </param>
        /// <returns>
        /// It returns a structure of type <typeparamref name="T"/>, read from the mapped BufferObject
        /// </returns>
        /// <exception cref="InvalidOperationException">
        /// Exception thrown if this BufferObject is not mapped (<see cref="Buffer.IsMapped"/>).
        /// </exception>
        public T GetElement <T>(uint index, uint sectionIndex) where T : struct
        {
            IArraySection arraySection = GetArraySection(sectionIndex);
            uint          stride       = arraySection.Stride != IntPtr.Zero ? (uint)arraySection.Stride.ToInt32() : ItemSize;
            ulong         itemOffset   = (ulong)arraySection.Offset.ToInt64() + stride * index;

            return(Get <T>(itemOffset));
        }
コード例 #2
0
        /// <summary>
        /// Set an element to this mapped ArrayBufferObjectBase.
        /// </summary>
        /// <typeparam name="T">
        /// A structure representing this ArrayBufferObjectBase element.
        /// </typeparam>
        /// <param name="value">
        /// A <typeparamref name="T"/> that specify the mapped BufferObject element.
        /// </param>
        /// <param name="index">
        /// A <see cref="uint"/> that specify the index of the element to set.
        /// </param>
        /// <param name="sectionIndex">
        /// A <see cref="uint"/> that specifies the array section index for supporting packed/interleaved arrays.
        /// </param>
        /// <exception cref="InvalidOperationException">
        /// Exception thrown if this BufferObject is not mapped (<see cref="IsMapped"/>).
        /// </exception>
        public void SetElement <T>(T value, uint index, uint sectionIndex) where T : struct
        {
            IArraySection arraySection = GetArraySection(sectionIndex);
            uint          stride       = arraySection.Stride != IntPtr.Zero ? (uint)arraySection.Stride.ToInt32() : ItemSize;
            ulong         itemOffset   = (ulong)arraySection.Offset.ToInt64() + stride * index;

            Set(value, itemOffset);
        }