/// <summary>
        /// Get the array components base type of the vertex array attribute item type.
        /// </summary>
        /// <param name="vertexArrayType">
        /// A <see cref="ArrayBufferItemType"/> that describe the vertex array attribute item type.
        /// </param>
        /// <returns>
        /// It returns a <see cref="VertexBaseType"/> indicating  the type of the components of
        /// the vertex array buffer item.
        /// </returns>
        public static ColorPointerType GetColorPointerType(this ArrayBufferItemType vertexArrayType)
        {
            switch (vertexArrayType.GetVertexBaseType())
            {
            case VertexBaseType.Byte:
                return(ColorPointerType.Byte);

            case VertexBaseType.UByte:
                return(ColorPointerType.UnsignedByte);

            case VertexBaseType.Short:
                return(ColorPointerType.Short);

            case VertexBaseType.UShort:
                return(ColorPointerType.UnsignedShort);

            case VertexBaseType.Int:
                return(ColorPointerType.Int);

            case VertexBaseType.UInt:
                return(ColorPointerType.UnsignedInt);

            case VertexBaseType.Float:
                return(ColorPointerType.Float);

#if !MONODROID
            case VertexBaseType.Double:
                return(ColorPointerType.Double);
#endif
            default:
                throw new NotSupportedException($"color pointer of type {vertexArrayType} not supported");
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="vertexArrayType"></param>
 public ArrayBufferItemAttribute(ArrayBufferItemType vertexArrayType)
 {
     ArrayType     = vertexArrayType;
     ArrayBaseType = vertexArrayType.GetVertexBaseType();
     ArrayLength   = vertexArrayType.GetArrayLength();
     ArrayRank     = vertexArrayType.GetArrayRank();
 }
        /// <summary>
        /// Get the array components base type of the vertex array attribute item type.
        /// </summary>
        /// <param name="vertexArrayType">
        /// A <see cref="ArrayBufferItemType"/> that describe the vertex array attribute item type.
        /// </param>
        /// <returns>
        /// It returns a <see cref="VertexBaseType"/> indicating  the type of the components of
        /// the vertex array buffer item.
        /// </returns>
        public static ColorPointerType GetColorPointerType(this ArrayBufferItemType vertexArrayType)
        {
            switch (vertexArrayType.GetVertexBaseType())
            {
            case VertexBaseType.Byte:
                return(ColorPointerType.Byte);

            case VertexBaseType.UByte:
                return(ColorPointerType.UnsignedByte);

            case VertexBaseType.Short:
                return(ColorPointerType.Short);

            case VertexBaseType.UShort:
                return(ColorPointerType.UnsignedShort);

            case VertexBaseType.Int:
                return(ColorPointerType.Int);

            case VertexBaseType.UInt:
                return(ColorPointerType.UnsignedInt);

            case VertexBaseType.Float:
                return(ColorPointerType.Float);

            case VertexBaseType.Double:
                return(ColorPointerType.Double);

            default:
                throw new NotSupportedException(String.Format("color pointer of type {0} not supported", vertexArrayType));
            }
        }
        /// <summary>
        /// Get the size of a vertex array buffer item, in bytes.
        /// </summary>
        /// <param name="vertexArrayType">
        /// A <see cref="ArrayBufferItemType"/> that describe the vertex array buffer item.
        /// </param>
        /// <returns>
        /// It returns the size of the vertex array buffer type having the type <paramref name="vertexArrayType"/>, in bytes.
        /// </returns>
        public static uint GetItemSize(this ArrayBufferItemType vertexArrayType)
        {
            uint baseTypeSize = vertexArrayType.GetVertexBaseType().GetSize();
            uint length       = vertexArrayType.GetArrayLength();
            uint rank         = vertexArrayType.GetArrayRank();

            return(baseTypeSize * length * rank);
        }
        /// <summary>
        /// Get the array components base type of the vertex array attribute item type.
        /// </summary>
        /// <param name="vertexArrayType">
        /// A <see cref="ArrayBufferItemType"/> that describe the vertex array attribute item type.
        /// </param>
        /// <returns>
        /// It returns a <see cref="VertexBaseType"/> indicating  the type of the components of
        /// the vertex array buffer item.
        /// </returns>
        public static TexCoordPointerType GetTexCoordPointerType(this ArrayBufferItemType vertexArrayType)
        {
            switch (vertexArrayType.GetVertexBaseType())
            {
            case VertexBaseType.Short:
                return(TexCoordPointerType.Short);

            case VertexBaseType.Int:
                return(TexCoordPointerType.Int);

            case VertexBaseType.Float:
                return(TexCoordPointerType.Float);

            case VertexBaseType.Double:
                return(TexCoordPointerType.Double);

            default:
                throw new NotSupportedException(String.Format("vertex pointer of type {0} not supported", vertexArrayType));
            }
        }
        /// <summary>
        /// Get the array components base type of the vertex array attribute item type.
        /// </summary>
        /// <param name="vertexArrayType">
        /// A <see cref="ArrayBufferItemType"/> that describe the vertex array attribute item type.
        /// </param>
        /// <returns>
        /// It returns a <see cref="VertexBaseType"/> indicating  the type of the components of
        /// the vertex array buffer item.
        /// </returns>
        public static TexCoordPointerType GetTexCoordPointerType(this ArrayBufferItemType vertexArrayType)
        {
            switch (vertexArrayType.GetVertexBaseType())
            {
            case VertexBaseType.Short:
                return(TexCoordPointerType.Short);

            case VertexBaseType.Int:
                return(TexCoordPointerType.Int);

            case VertexBaseType.Float:
                return(TexCoordPointerType.Float);

#if !MONODROID
            case VertexBaseType.Double:
                return(TexCoordPointerType.Double);
#endif
            default:
                throw new NotSupportedException($"vertex pointer of type {vertexArrayType} not supported");
            }
        }
Beispiel #7
0
        /// <summary>
        /// Get the array components base type of the vertex array attribute item type.
        /// </summary>
        /// <param name="vertexArrayType">
        /// A <see cref="ArrayBufferItemType"/> that describe the vertex array attribute item type.
        /// </param>
        /// <returns>
        /// It returns a <see cref="VertexBaseType"/> indicating  the type of the components of
        /// the vertex array buffer item.
        /// </returns>
        public static NormalPointerType GetNormalPointerType(this ArrayBufferItemType vertexArrayType)
        {
            switch (vertexArrayType.GetVertexBaseType())
            {
            case VertexBaseType.Byte:
                return(NormalPointerType.Byte);

            case VertexBaseType.Short:
                return(NormalPointerType.Short);

            case VertexBaseType.Int:
                return(NormalPointerType.Int);

            case VertexBaseType.Float:
                return(NormalPointerType.Float);

#if !MONODROID
            case VertexBaseType.Double:
                return(NormalPointerType.Double);
#endif
            default:
                throw new NotSupportedException(String.Format("normal pointer of type {0} not supported", vertexArrayType));
            }
        }
 /// <summary>
 /// Determine whether a vertex array type is composed by floating-point value(s).
 /// </summary>
 public static bool IsFloatBaseType(this ArrayBufferItemType vertexArrayType)
 {
     return(vertexArrayType.GetVertexBaseType().IsFloatBaseType());
 }
Beispiel #9
0
 /// <summary>
 /// Check whether a <see cref="VertexBaseType"/> is supported by current OpenGL implementation.
 /// </summary>
 /// <param name="ctx">
 /// A <see cref="GraphicsContext"/> that specify the OpenGL implementation.
 /// </param>
 /// <param name="arrayType">
 /// A <see cref="ArrayBufferItemType"/> to test for support.
 /// </param>
 /// <returns>
 /// It returns a boolean value indicating whether vertex attributes data can be specified with vertices having
 /// the base type <paramref name="arrayType"/>.
 /// </returns>
 public static bool IsDataSupported(GraphicsContext ctx, ArrayBufferItemType arrayType)
 {
     return(IsDataSupported(ctx, arrayType.GetVertexBaseType()));
 }