コード例 #1
0
        public static IBuffer<float> CreateVertexBuffer(ICollection<Point> points, ref BoundingBox bounds)
        {
            var buffer = new VertexBuffer(2 * points.Count);

            bounds.Reset();

            var data = buffer.Data;

            float x, y;

            int i = 0;

            foreach (var p in points)
            {
                x = (float)p.X;
                y = (float)p.Y;

                data[2 * i] = x;
                data[2 * i + 1] = y;

                bounds.Update(x, y);

                i++;
            }

            return buffer as IBuffer<float>;
        }
コード例 #2
0
        public static IBuffer<float> CreateVertexBuffer(double[] points, ref BoundingBox bounds)
        {
            int length = points.Length;

            var buffer = new VertexBuffer(length);

            bounds.Reset();

            var data = buffer.Data;

            float x, y;

            length = length >> 1;

            for (int i = 0; i < length; i++)
            {
                x = (float)points[2 * i];
                y = (float)points[2 * i + 1];

                data[2 * i] = x;
                data[2 * i + 1] = y;

                bounds.Update(x, y);
            }

            return buffer as IBuffer<float>;
        }