Exemple #1
0
 public GLVertexArrayObject(int handle, GLProgram program, GLBuffer vertexBuffer, GLBuffer indexBuffer)
 {
     Handle = handle;
     Program = program;
     VertexBuffer = vertexBuffer;
     IndexBuffer = indexBuffer;
 }
Exemple #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);
        }
Exemple #3
0
 public VectorMesh(GLBuffer vertexBuffer, GLBuffer indexBuffer, int indexCount)
 {
     VertexBuffer = vertexBuffer;
     IndexBuffer = indexBuffer;
     IndexCount = indexCount;
 }
Exemple #4
0
 public SpriteBatchBuffer(GLBuffer vertexBuffer, GLBuffer indexBuffer, uint indexCount)
 {
     VertexBuffer = vertexBuffer;
     IndexBuffer = indexBuffer;
     IndexCount = indexCount;
 }