嘿,我遇到了一点麻烦。我使用 xna 已经有一段时间了,但我对 3D 完全陌生。我正在逐字跟踪 msdn 网站上 winformsgraphicsdevice 示例中的代码。它有一个可以在屏幕上绘制一个原始三角形的控件。就这么简单,但我在这一行遇到了一个例外:
GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, vertices, 0, 1);
其中说:
"The current vertex declaration does not include all the elements required by the current vertex shader. Normal0 is missing."
我假设这与我的VertexPositionColor
多变的,vertices
。该代码在这里:
vertices = new VertexPositionColor[3];
vertices[0] = new VertexPositionColor(new Vector3(-1, -1, 0), Color.Black);
vertices[1] = new VertexPositionColor(new Vector3( 1, -1, 0), Color.Black);
vertices[2] = new VertexPositionColor(new Vector3(0, 1, 0), Color.Black);