示例#1
0
 public GLVertexArrayObject(int handle, GLProgram program, GLBuffer vertexBuffer, GLBuffer indexBuffer)
 {
     Handle = handle;
     Program = program;
     VertexBuffer = vertexBuffer;
     IndexBuffer = indexBuffer;
 }
示例#2
0
        public GLVertexArrayObject GetVAO(GLBuffer vertexBuffer, GLBuffer indexBuffer)
        {
            int vaoHandle = GL.GenVertexArray();
            GL.BindVertexArray(vaoHandle);

            GL.BindBuffer(BufferTarget.ArrayBuffer, vertexBuffer.Handle);
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, indexBuffer.Handle);

            var stride = Signature.Attributes.Sum(e => e.SizeInBytes());

            var attributeOffset = 0;
            for (int i = 0; i < Signature.Attributes.Length; i++)
            {
                var attribute = Signature.Attributes[i];

                GL.VertexAttribPointer(attribute.Location, attribute.GetComponentCount(), attribute.GetComponentType(),
                            false, stride, attributeOffset);
                GL.EnableVertexAttribArray(attribute.Location);
                GL.BindAttribLocation(Handle, attribute.Location, attribute.Name);

                attributeOffset += attribute.SizeInBytes();
            }

            GL.BindVertexArray(0);
            GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);

            return new GLVertexArrayObject(vaoHandle, this, vertexBuffer, indexBuffer);
        }
示例#3
0
 public VectorMesh(GLBuffer vertexBuffer, GLBuffer indexBuffer, int indexCount)
 {
     VertexBuffer = vertexBuffer;
     IndexBuffer = indexBuffer;
     IndexCount = indexCount;
 }
示例#4
0
 public SpriteBatchBuffer(GLBuffer vertexBuffer, GLBuffer indexBuffer, uint indexCount)
 {
     VertexBuffer = vertexBuffer;
     IndexBuffer = indexBuffer;
     IndexCount = indexCount;
 }