Ejemplo n.º 1
0
        public static Vbo AcquireVbo(this IShape shape, VboType vboType)
        {
            var vbo = Vbos.FirstOrDefault(p => p.Matches(shape, vboType));

            if (vbo == null)
            {
                Vbos.Add(vbo = new Vbo(shape, vboType));
            }
            vbo.AddRef();
            return(vbo);
        }
Ejemplo n.º 2
0
        public Vbo(IShape shape, VboType vboType)
        {
            if (shape == null)
            {
                return;
            }
            _pattern     = shape.Pattern;
            _stripeCount = shape.StripeCount;
            _vboType     = vboType;
            GL.GenBuffers(1, out int buffer);
            BufferID = buffer;
            GL.BindBuffer(BufferTarget, BufferID);
            switch (_vboType)
            {
            case VboType.Vertex:
                BufferData(shape.GetCoordsCount() * sizeof(float), shape.GetCoords());
                break;

            case VboType.Index:
                ElementsCount = shape.GetIndicesCount();
                BufferData(ElementsCount * sizeof(int), shape.GetIndices());
                break;
            }
        }
Ejemplo n.º 3
0
 public bool Matches(IShape shape, VboType vboType) =>
 shape != null && _vboType == vboType &&
 _stripeCount.EquiAxial(shape.StripeCount) &&
 (_vboType != VboType.Index || _pattern == shape.Pattern);