Esempio n. 1
0
        public Mesh(MeshVertex[] vertices, ushort[] indices)
        {
            this.Vertices = vertices;
            this.Indices  = indices;

            VA = new VertexArray();
            VA.Bind();

            VertexBuffer vb = new VertexBuffer();

            vb.SetData((uint)(System.Runtime.InteropServices.Marshal.SizeOf(typeof(MeshVertex)) * vertices.Length), vertices);

            BufferLayout layout = new BufferLayout();

            layout.Push <Vector3>("POSITION");
            layout.Push <Vector2>("TEXCOORD");
            layout.Push <Vector3>("NORMAL");
            layout.Push <Vector3>("BITANGENT");
            layout.Push <Vector3>("TANGENT");
            layout.Push <Vector4>("COLOR");

            vb.SetLayout(layout);

            VA.PushBuffer(vb);

            IB = new IndexBuffer(indices, (uint)indices.Length);

            VA.Unbind();
        }