Share via


Device.Device

Device メソッド

使用例

  • Direct3D デバイスの作成

オブジェクトの新しいインスタンスを初期化する。

オーバーロード リスト

public  Device (Int32, DeviceType, IntPtr, CreateFlags, PresentParameters)
public  Device (Int32, DeviceType, Control, CreateFlags, PresentParameters)
public  Device (IntPtr)

使用例

Direct3D デバイスの作成

この例では、レンダリングに使う Microsoft® Direct3D® Device およびデータ格納に使う VertexBuffer を作成する方法を示す。

  1. 作成される Device オブジェクトを利用すれば、多くのメソッド、プロパティ、イベントを使って、3D ポリゴン モデルのライティング、テクスチャ、シェーディング、レンダリングを制御できる。
  2. VertexBuffer オブジェクトは、モデルの頂点データのデータ格納リソースとして利用される。

この例では、ウィンドウの作成と操作用に、Vertices クラスが Form 型で宣言されている。

using Microsoft.DirectX.Direct3D;
.
.
.
public class Vertices : System.Windows.Forms.Form
{
    // Global variables for this project
    Device device = null;              // 1. Create rendering device
    VertexBuffer vertexBuffer = null;  // 2. Create vertex buffer
    PresentParameters presentParams = new PresentParameters();
    
    public bool InitializeGraphics()
    {
        try
        {
            device = new Device(0, DeviceType.Hardware, this, 
                        CreateFlags.SoftwareVertexProcessing, presentParams);
            vertexBuffer = new VertexBuffer(
                        typeof(CustomVertex.PositionColored), 3, dev, 0,
                        CustomVertex.PositionColored.Format, Pool.Default);
            pause = false;
            return true;
        }
        catch { return false; }
    }
        
// Call InitializeGraphics from Main...
    
}

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