Beispiel #1
0
        public void AddVertexBuffer(IVertexBuffer vertexBuffer)
        {
            Debug.Assert(vertexBuffer.GetLayout().Elements.Length != 0, "Vertex buffer has no layout!");

            Gl.BindVertexArray(rendererID);
            vertexBuffer.Bind();

            uint index = 0;

            foreach (BufferElement element in vertexBuffer.GetLayout().Elements)
            {
                Gl.EnableVertexAttribArray(index);
                Gl.VertexAttribPointer(index,
                                       (int)element.GetComponentCount(),
                                       ShaderDataTypeToOpenGLBaseType(element.Type),
                                       element.Normalized,
                                       (int)vertexBuffer.GetLayout().Stride,
                                       (IntPtr)element.Offset);
                index++;
            }

            vertexBuffers.Add(vertexBuffer);
        }