まず第一に、私は XNA と、GPU がどのように機能し、XNA (または DirectX) API とどのように連携するかについては初めてです。
SpriteBatch を使用して描画するポリゴンがあります。ポリゴンを三角測量しVertexPositionTexture
、頂点を保持する配列を作成しています。頂点を設定し (簡単にするために、テクスチャ オフセット ベクトルをゼロに設定し)、プリミティブを描画しようとしましたが、次のエラーが発生しました。
The current vertex declaration does not include all the elements required by the current vertex shader. Color0 is missing.
これが私のコードです。三角形分割からのベクトルを再確認しましたが、問題ありません。
VertexPositionTexture[] vertices = new VertexPositionTexture[triangulationResult.Count * 3];
int ctr = 0;
foreach (var item in triangulationResult)
{
foreach (var point in item.Vertices)
{
vertices[ctr++] = new VertexPositionTexture(new Vector3(point.X, point.Y, 0), Vector2.Zero);
}
}
sb.GraphicsDevice.DrawUserPrimitives<VertexPositionTexture>(PrimitiveType.TriangleList, vertices, 0, triangulationResult.Count);
ここで何が間違っているのでしょうか?