public QuadVertexBuffer(int amountQuads, BufferUsageHint usage)
            : base(amountQuads * 4, usage)
        {
            int amountIndices = amountQuads * 6;

            if (amountIndices > QuadIndexData.MaxAmountIndices)
            {
                ushort[] indices = new ushort[amountIndices];

                for (ushort i = 0, j = 0; j < amountIndices; i += 4, j += 6)
                {
                    indices[j]     = i;
                    indices[j + 1] = (ushort)(i + 1);
                    indices[j + 2] = (ushort)(i + 3);
                    indices[j + 3] = (ushort)(i + 2);
                    indices[j + 4] = (ushort)(i + 3);
                    indices[j + 5] = (ushort)(i + 1);
                }

                OsuGlControl.BindBuffer(BufferTarget.ElementArrayBuffer, QuadIndexData.EboId);
                GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(amountIndices * sizeof(ushort)), indices, BufferUsageHint.StaticDraw);

                QuadIndexData.MaxAmountIndices = amountIndices;
            }
        }
Exemple #2
0
        public override void Bind(bool forRendering)
        {
            base.Bind(forRendering);

            if (forRendering)
            {
                OsuGlControl.BindBuffer(BufferTarget.ElementArrayBuffer, LinearIndexData.EboId);
            }
        }
        public virtual void Bind(bool forRendering)
        {
            Debug.Assert(!isDisposed);

            if (OsuGlControl.BindBuffer(BufferTarget.ArrayBuffer, vboId))
            {
                bindAttributes();
            }
        }
Exemple #4
0
        public LinearVertexBuffer(int amountVertices, BeginMode type, BufferUsageHint usage)
            : base(amountVertices, usage)
        {
            this.type = type;

            if (amountVertices > LinearIndexData.MaxAmountIndices)
            {
                ushort[] indices = new ushort[amountVertices];

                for (ushort i = 0; i < amountVertices; i++)
                {
                    indices[i] = i;
                }

                OsuGlControl.BindBuffer(BufferTarget.ElementArrayBuffer, LinearIndexData.EboId);
                GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(amountVertices * sizeof(ushort)), indices, BufferUsageHint.StaticDraw);

                LinearIndexData.MaxAmountIndices = amountVertices;
            }
        }
        public void Resize(int amountVertices)
        {
            Debug.Assert(!isDisposed);

            T[] oldVertices = Vertices;
            Vertices = new T[amountVertices];

            if (oldVertices != null)
            {
                for (int i = 0; i < oldVertices.Length && i < Vertices.Length; ++i)
                {
                    Vertices[i] = oldVertices[i];
                }
            }

            if (OsuGlControl.BindBuffer(BufferTarget.ArrayBuffer, vboId))
            {
                bindAttributes();
            }

            GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(Vertices.Length * stride), IntPtr.Zero, usage);
        }