Example #1
0
        private void resize(int amountVertices)
        {
            if (IsDisposed)
            {
                throw new ObjectDisposedException(ToString(), "Can not resize disposed vertex buffers.");
            }

            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 (GLWrapper.BindBuffer(BufferTarget.ArrayBuffer, vboId))
            {
                VertexUtils <T> .Bind();
            }

            GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(Vertices.Length * STRIDE), IntPtr.Zero, usage);
        }
Example #2
0
        /// <summary>
        /// Initialises this <see cref="VertexBuffer{T}"/>. Guaranteed to be run on the draw thread.
        /// </summary>
        protected virtual void Initialise()
        {
            ThreadSafety.EnsureDrawThread();

            GL.GenBuffers(1, out vboId);

            if (GLWrapper.BindBuffer(BufferTarget.ArrayBuffer, vboId))
                VertexUtils<DepthWrappingVertex<T>>.Bind();

            GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(vertices.Length * STRIDE), IntPtr.Zero, usage);
        }
Example #3
0
        public virtual void Bind(bool forRendering)
        {
            if (IsDisposed)
            {
                throw new ObjectDisposedException(ToString(), "Can not bind disposed vertex buffers.");
            }

            if (GLWrapper.BindBuffer(BufferTarget.ArrayBuffer, vboId))
            {
                VertexUtils <T> .Bind();
            }
        }
Example #4
0
        public virtual void Bind(bool forRendering)
        {
            if (IsDisposed)
                throw new ObjectDisposedException(ToString(), "Can not bind disposed vertex buffers.");

            if (!isInitialised)
            {
                Initialise();
                isInitialised = true;
            }

            if (GLWrapper.BindBuffer(BufferTarget.ArrayBuffer, vboId))
                VertexUtils<DepthWrappingVertex<T>>.Bind();
        }
Example #5
0
        private void resize(int amountVertices)
        {
            if (IsDisposed)
            {
                throw new ObjectDisposedException(ToString(), "Can not resize disposed vertex buffers.");
            }

            Array.Resize(ref Vertices, amountVertices);

            if (GLWrapper.BindBuffer(BufferTarget.ArrayBuffer, vboId))
            {
                VertexUtils <T> .Bind();
            }

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