은 이미 그들이 XNA에서 2D 선을 그릴하는 방법을 설명합니다,하지만 난이 exeption를 얻을XNA - 그리기 2D 라인
{
int points = 3;//I tried different values(1,2,3,4)
VertexPositionColor[] primitiveList = new VertexPositionColor[points];
for (int x = 0; x < points/2; x++)
{
for (int y = 0; y < 2; y++)
{
primitiveList[(x * 2) + y] = new VertexPositionColor(
new Vector3(x * 100, y * 100, 0), Color.White);
}
}
// Initialize an array of indices of type short.
short[] lineListIndices = new short[(points * 2) - 2];
// Populate the array with references to indices in the vertex buffer
for (int i = 0; i < points - 1; i++)
{
lineListIndices[i * 2] = (short)(i);
lineListIndices[(i * 2) + 1] = (short)(i + 1);
}
GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(
PrimitiveType.LineList,
primitiveList,
0, // vertex buffer offset to add to each element of the index buffer
8, // number of vertices in pointList
lineListIndices, // the index buffer
0, // first index element to read
7 // number of primitives to draw
); <---This parameter must be a valid index within the array. Parameter name: primitiveCount
}
(스크립트를 참조)하지만 난 해결하는 방법에 아무 생각이 여기 http://msdn.microsoft.com/en-us/library/bb196414.aspx#ID2EEF 보았다 이, 이것은 3d 렌더링을 사용하여 2D 그래픽을 내 처음부터
배경 :
메신저 XNA에 대한 2D 게임 엔진을 제작하고, 나는 이미 당신을 알고, 간단한 그림을 그리기위한 클래스를 만들 을 원한다 1x1을 사용할 수있다. 그리기를위한 Texture2D 픽셀 속임수지만, GPU가 이것을 쉽게 처리 할 수있는 동안 CPU가 모든 계산을 수행 할 것이기 때문에이 방법도 알고 싶습니다.
이 라이브러리를 사용하고 있습니다. https://bitbucket.org/C3/2d-xna-primitives/wiki/Home – Dmi7ry