Ejemplo n.º 1
0
        private void UploadBufferToGPU <T>(ShaderAttributeIds attribute, T[] data) where T : struct
        {
            // See if this attribute is already enabled. If it's not already enabled, we need to generate a buffer for it.
            if (!VertexDescription.AttributeIsEnabled(attribute))
            {
                VertexDescription.EnableAttribute(attribute);
            }

            // Bind the buffer before updating the data.
            GL.BindBuffer(BufferTarget.ArrayBuffer, VertexDescription.GetAttributeBufferId(attribute));

            // Finally, update the data.
            int stride = VertexDescription.GetStride(attribute);

            GL.BufferData <T>(BufferTarget.ArrayBuffer, (IntPtr)(data.Length * stride), data, BufferUsageHint.StaticDraw);
        }
Ejemplo n.º 2
0
            public void Bind()
            {
                for (int i = 0; i < m_glBufferIndexes.Length; i++)
                {
                    ShaderAttributeIds id = (ShaderAttributeIds)i;
                    if (VertexDescription.AttributeIsEnabled(id))
                    {
                        GL.BindBuffer(BufferTarget.ArrayBuffer, m_glBufferIndexes[i]);
                        GL.EnableVertexAttribArray(i);
                        GL.VertexAttribPointer(i, VertexDescription.GetAttributeSize(id), VertexDescription.GetAttributePointerType(id), false, VertexDescription.GetStride(id), 0);
                    }
                }

                // Bind the Element Array Buffer as well
                GL.BindBuffer(BufferTarget.ElementArrayBuffer, m_glIndexBuffer);
            }