我創建了一個邊界框,並且想要查看它的位置。它被定義爲四個角,我只是想在這四個角之間畫線。應用程序關閉時沒有繪製線條(在調試模式下)
我設法谷歌如何做到這一點:
public void Draw(GraphicsDevice graphicsDevice)
{
int num = mCorners.Length;
VertexPositionColor[] primitiveList = new VertexPositionColor[num];
for (int i = 0; i < num; ++i)
{
primitiveList[i] = new VertexPositionColor(new Vector3(mCorners[i], 0), Color.White);
}
short[] triangleStripIndices = new short[] { 0, 1, 2, 3, };
graphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(PrimitiveType.LineStrip, primitiveList, 0, 4, triangleStripIndices, 0, 3);
}
然而,當這個代碼運行的應用程序只是關閉。它處於調試模式,但沒有堆棧跟蹤,崩潰消息,錯誤日誌等。它只是關閉,使其非常難以調試。
我發現了一個沒有答案的類似問題: XNA 4.0 app closes suddenly when it hits a method without throwing any exceptions。建議是它被正確地初始化,並且是我的。 GraphicsDevice作爲參數傳遞並且不是靜態獲得的。
有沒有人知道可能是什麼原因造成的?
感謝,
感謝您的回覆。我的對象沒有對Dispatcher的引用,我在哪裏可以找到它以便我可以使用它?我發現它在System.Windows.Threading命名空間下,並在我的文件中添加了一個using語句,但我仍然無法獲取它。謝謝 – Luke
更新:我發現它包含System.Windows DLL並執行Deployment.Current.Dispatcher。 我現在得到一個單一的框架(只要我可以告訴沒有線被繪製),然後它關閉而不提供任何信息。 – Luke