Ejemplo n.º 1
0
        public static int SizeOf(ComponentDatatype type)
        {
            switch (type)
            {
            case ComponentDatatype.Byte:
            case ComponentDatatype.UnsignedByte:
                return(sizeof(byte));

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

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

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

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

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

            case ComponentDatatype.HalfFloat:
                return(SizeInBytes <Half> .Value);
            }

            throw new ArgumentException("type");
        }
Ejemplo n.º 2
0
 public VertexBufferAttribute(
     VertexBuffer vertexBuffer,
     ComponentDatatype componentDatatype,
     int numberOfComponents)
     : this(vertexBuffer, componentDatatype, numberOfComponents, false, 0, 0)
 {
 }
Ejemplo n.º 3
0
 public VertexBufferAttribute(
     VertexBuffer vertexBuffer,
     ComponentDatatype componentDatatype,
     int numberOfComponents)
     : this(vertexBuffer, componentDatatype, numberOfComponents, false, 0, 0)
 {
 }
Ejemplo n.º 4
0
        public static VertexAttribPointerType To(ComponentDatatype type)
        {
            switch (type)
            {
            case ComponentDatatype.Byte:
                return(VertexAttribPointerType.Byte);

            case ComponentDatatype.UnsignedByte:
                return(VertexAttribPointerType.UnsignedByte);

            case ComponentDatatype.Short:
                return(VertexAttribPointerType.Short);

            case ComponentDatatype.UnsignedShort:
                return(VertexAttribPointerType.UnsignedShort);

            case ComponentDatatype.Int:
                return(VertexAttribPointerType.Int);

            case ComponentDatatype.UnsignedInt:
                return(VertexAttribPointerType.UnsignedInt);

            case ComponentDatatype.Float:
                return(VertexAttribPointerType.Float);

            case ComponentDatatype.HalfFloat:
                return(VertexAttribPointerType.HalfFloat);
            }

            throw new ArgumentException("type");
        }
Ejemplo n.º 5
0
        public VertexBufferAttribute(
            VertexBuffer vertexBuffer,
            ComponentDatatype componentDatatype,
            int numberOfComponents,
            bool normalize,
            int offsetInBytes,
            int strideInBytes)
        {
            if (numberOfComponents <= 0)
            {
                throw new ArgumentOutOfRangeException("numberOfComponents", "numberOfComponents must be greater than zero.");
            }

            if (offsetInBytes < 0)
            {
                throw new ArgumentOutOfRangeException("offsetInBytes", "offsetInBytes must be greater than or equal to zero.");
            }

            if (strideInBytes < 0)
            {
                throw new ArgumentOutOfRangeException("stride", "stride must be greater than or equal to zero.");
            }

            _vertexBuffer       = vertexBuffer;
            _componentDatatype  = componentDatatype;
            _numberOfComponents = numberOfComponents;
            _normalize          = normalize;
            _offsetInBytes      = offsetInBytes;

            if (strideInBytes == 0)
            {
                //
                // Tightly packed
                //
                _strideInBytes = numberOfComponents * VertexArraySizes.SizeOf(componentDatatype);
            }
            else
            {
                _strideInBytes = strideInBytes;
            }
        }
Ejemplo n.º 6
0
        public VertexBufferAttribute(
            VertexBuffer vertexBuffer,
            ComponentDatatype componentDatatype,
            int numberOfComponents,
            bool normalize,
            int offsetInBytes,
            int strideInBytes)
        {
            if (numberOfComponents <= 0)
            {
                throw new ArgumentOutOfRangeException("numberOfComponents", "numberOfComponents must be greater than zero.");
            }

            if (offsetInBytes < 0)
            {
                throw new ArgumentOutOfRangeException("offsetInBytes", "offsetInBytes must be greater than or equal to zero.");
            }

            if (strideInBytes < 0)
            {
                throw new ArgumentOutOfRangeException("stride", "stride must be greater than or equal to zero.");
            }

            _vertexBuffer = vertexBuffer;
            _componentDatatype = componentDatatype;
            _numberOfComponents = numberOfComponents;
            _normalize = normalize;
            _offsetInBytes = offsetInBytes;

            if (strideInBytes == 0)
            {
                //
                // Tightly packed
                //
                _strideInBytes = numberOfComponents * VertexArraySizes.SizeOf(componentDatatype);
            }
            else
            {
                _strideInBytes = strideInBytes;
            }
        }
Ejemplo n.º 7
0
        public static int SizeOf(ComponentDatatype type)
        {
            switch (type)
            {
                case ComponentDatatype.Byte:
                case ComponentDatatype.UnsignedByte:
                    return sizeof(byte);
                case ComponentDatatype.Short:
                    return sizeof(short);
                case ComponentDatatype.UnsignedShort:
                    return sizeof(ushort);
                case ComponentDatatype.Int:
                    return sizeof(int);
                case ComponentDatatype.UnsignedInt:
                    return sizeof(uint);
                case ComponentDatatype.Float:
                    return sizeof(float);
                case ComponentDatatype.HalfFloat:
                    return SizeInBytes<Half>.Value;
            }

            throw new ArgumentException("type");
        }
Ejemplo n.º 8
0
        public static VertexAttribPointerType To(ComponentDatatype type)
        {
            switch (type)
            {
                case ComponentDatatype.Byte:
                    return VertexAttribPointerType.Byte;
                case ComponentDatatype.UnsignedByte:
                    return VertexAttribPointerType.UnsignedByte;
                case ComponentDatatype.Short:
                    return VertexAttribPointerType.Short;
                case ComponentDatatype.UnsignedShort:
                    return VertexAttribPointerType.UnsignedShort;
                case ComponentDatatype.Int:
                    return VertexAttribPointerType.Int;
                case ComponentDatatype.UnsignedInt:
                    return VertexAttribPointerType.UnsignedInt;
                case ComponentDatatype.Float:
                    return VertexAttribPointerType.Float;
                case ComponentDatatype.HalfFloat:
                    return VertexAttribPointerType.HalfFloat;
            }

            throw new ArgumentException("type");
        }