Пример #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);
        }
Пример #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);
        }
Пример #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();
            }
        }
Пример #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();
        }
Пример #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);
        }