Example #1
0
    public static int SizeOf(VertexAttribPointerType type)
    {
        switch (type)
        {
        case VertexAttribPointerType.Byte:
            return(sizeof(sbyte));

        case VertexAttribPointerType.UnsignedByte:
            return(sizeof(byte));

        case VertexAttribPointerType.Short:
            return(sizeof(short));

        case VertexAttribPointerType.UnsignedShort:
            return(sizeof(ushort));

        case VertexAttribPointerType.Int:
            return(sizeof(int));

        case VertexAttribPointerType.UnsignedInt:
            return(sizeof(uint));

        case VertexAttribPointerType.Float:
            return(sizeof(float));

        case VertexAttribPointerType.Double:
            return(sizeof(double));

        default:
            throw new InvalidEnumArgumentException(type.ToString());
        }
    }
 /// <summary>
 /// Returns the size in bytes of the C# equivalent for a specified OpenGL attribute pointer type.
 /// </summary>
 /// <returns>The size of <paramref name="type"/> in bytes</returns>
 /// <exception cref="System.NotImplementedException">The size of <paramref name="type"/> is not implemented</exception>
 public static int GetSizeInBytes(VertexAttribPointerType type)
 {
     if (sizeInBytesByType.ContainsKey(type))
     {
         return(sizeInBytesByType[type]);
     }
     else
     {
         throw new System.NotImplementedException($"{type.ToString()} is not a supported type.");
     }
 }
        public override string ToString()
        {
            if (IsPadding)
            {
                return(string.Concat("Padding=", SizeInBytes.ToString(), " bytes"));
            }

            return(string.Concat(
                       Normalized ? "Normalized " : "Unnormalized ", AttribType.ToString(),
                       ", " + nameof(AttribBaseType) + "=", AttribBaseType.ToString(),
                       ", " + nameof(AttribIndicesUseCount) + "=", AttribIndicesUseCount.ToString(),
                       ", " + nameof(AttribDivisor) + "=", AttribDivisor.ToString()
                       ));
        }
Example #4
0
        /// <summary>
        /// Gets the size in bytes of the given <see cref="VertexAttribPointerType"/>.
        /// </summary>
        public static uint GetVertexAttribSizeInBytes(VertexAttribPointerType type)
        {
            switch (type)
            {
            case VertexAttribPointerType.Byte:
            case VertexAttribPointerType.UnsignedByte:
                return(1);

            case VertexAttribPointerType.Short:
            case VertexAttribPointerType.UnsignedShort:
            case VertexAttribPointerType.HalfFloat:
                return(2);

            case VertexAttribPointerType.Float:
            case VertexAttribPointerType.Int:
            case VertexAttribPointerType.UnsignedInt:
            case VertexAttribPointerType.Fixed:
                return(4);

            case VertexAttribPointerType.Double:
                return(8);

            default:
                throw new NotSupportedException(string.Concat("Cannot get size for " + nameof(VertexAttribPointerType) + ":", type.ToString()));
            }
        }