C#のDirectXに問題があります。線を引きたいです。まず、DrawUserPrimitivesを使用して実行しましたが、すべて問題ありません。しかし、回転やその他のカメラアクションを実行したいので、vertexBufferに切り替えました。そして、私は窓に何も見えません。
平面上にvertexBufferを埋め、頂点を描画するコードの一部があります。
vertexBuffer = new VertexBuffer(typeof(CustomVertex.PositionColored),
8 * (CurrentPanel.ElementsCount() + 1), m_device, Usage.None,
CustomVertex.PositionColored.Format, Pool.Default);
CustomVertex.PositionColored[] verts =
(CustomVertex.PositionColored[])vertexBuffer.Lock(0, 0);
//this function returns array of verts based on given points.
verts = CurrentPanel.GetLines();
vertexBuffer.Unlock();
m_device.Clear(ClearFlags.Target, System.Drawing.Color.FromArgb(255, 255, 255).ToArgb(), 1.0f, 0);
m_device.BeginScene(); //m_device is my DirectX.Device
SetupViewport(); //Set all of matrixes...
m_device.SetStreamSource(0, vertexBuffer, 0);
m_device.VertexFormat = CustomVertex.PositionColored.Format;
//m_device.DrawUserPrimitives(PrimitiveType.LineList, CurrentPanel.ElementsCount() * 4, verts); // <- WHEN I USE THIS ALL IS OK
m_device.DrawPrimitives(PrimitiveType.LineList, 0, 4*(CurrentPanel.ElementsCount()+1)); //<-DO NOT WORK
m_device.EndScene();
m_device.Present();
このコードはMicrosoftDirectXサンプルに基づいていることを付け加えたいと思います。