Share via


シーンの生成

シーンの生成

この例では、シーンの生成を開始して、プリミティブを描画する方法を示す。

SetStreamSource メソッドは、頂点バッファをデバイス データ ストリームにバインドし、頂点データと、プリミティブ処理関数にデータを供給するデータ ストリーム ポートの 1 つとを関連付ける。このメソッドの引数は、データ ストリームの数、VertexBuffer オブジェクトの名前、ストリームの頂点ストライドである。

この例では、DrawPrimitives は、PrimitiveType 列挙の TriangleList 定数または TriangleStrip 定数のいずれかを使って、プリミティブをレンダリングできる。

using Microsoft.DirectX.Direct3D;

// Define custom vertex format
private struct customVertex
{
    // Define structure
}

Device device = null;        // Create rendering device
VertexBuffer vBuffer = null; // Create vertex buffer

// Begin the scene
device.BeginScene();

device.SetStreamSource( 0, vBuffer, 0);

// Assign custom vertex type, in this case a transformed, lit, and colored format
device.VertexFormat = CustomVertex.TransformedLitColored.Format;
device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);

// Alternative primitive rendering using TriangleStrip
// device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, (4*25)-2);

© 2002 Microsoft Corporation. All rights reserved. Terms of use.