close

在XNA 4.0用 REACH 版本,用基本特效畫出3D地板的時候,出現了以下的錯誤訊息:

XNA Framework Reach profile does not support 32 bit indices. Use IndexElementSize.SixteenBits or a type that has a size of two bytes.

google翻譯寫:

    XNA框架REACH配置文件不支持32位指數。使用IndexElementSize.SixteenBits或類型,有兩個字節的大小。

SixteenBits是16位元,

我在網路上找不到答案,心想只能靠自己了~~~~

以下是SOURCE CODE

foreach (EffectPass pass in mBasicEffect.CurrentTechnique.Passes)
{
pass.Apply();

//畫線的函式
GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, vertices, 0, 4, indices, 0, 2);
//參數:
//primitiveType 畫圖型態, vertexData 點的陣列, vertexOffset 點開始位置, numVertices 畫幾個點,indexData 索引陣列,indexOffset 索引起點,primitiveCount 索引有幾組
}

DrawUserIndexedPrimitives 有一個參數 indexData 索引陣列, 我發現我是用 int , 它是32位元 ,於是我把他改成 short (16位元) ,沒想到這樣一改就成功了!!!

arrow
arrow
    全站熱搜

    createps 發表在 痞客邦 留言(0) 人氣()