最近在绘制3D的地形,128*128的毫无问题,但绘制256时就出问题,当视野里的三角形数量大到一定程度后,会导致渲染失败。查了查MSDN才知,DrawIndexedPrimitive绘制三角形是有个数限制的。
MaxPrimitiveCount
Maximum number of primitives for each DrawPrimitive call. Note that when Direct3D is working with a DirectX 6.0 or DirectX 7.0 driver, this field is set to 0xFFFF(65535). This means that not only the number of primitives but also the number of vertices is limited by this value.
MaxVertexIndex
Maximum size of indices supported for hardware vertex processing. It is possible to create 32-bit index buffers by specifying D3DFMT_INDEX32; however, you will not be able to render with the index buffer unless this value is greater than 0x0000FFFF.
找出问题才好,要不心里不踏实啊。
解决方案:把顶点数组和索引数组分成几组,然后多次调用DrawIndexedPrimitive解决。