首先,我是XNA的新手,GPU的工作原理以及它如何與XNA(或DirectX)API協作。DrawUserPrimitives <VertexPositionTexture>對頂點着色器缺少Color0抱怨
我有一個多邊形繪製使用SpriteBatch。我正在對多邊形進行三角測量,並創建一個數組來保存頂點。我設置了頂點(和公正爲簡單起見,紋理偏移向量設置爲零),並嘗試繪製的圖元,但我得到這個錯誤:
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);
我在這裏可能做錯了什麼?