Device.DeviceCreated
DeviceCreated イベント
使用例
- Direct3D ディスプレイ フォーマットの設定
デバイスが作成された時点で発生する。
定義
Visual Basic | Public Event DeviceCreated As EventHandler |
C# | public event EventHandler DeviceCreated; |
Managed C++ | public: __event DeviceCreated; |
JScript | イベントは使えるが、独自に定義することはできない。 |
使用例
Direct3D ディスプレイ フォーマットの設定
この例では、ポリゴン モデルのプレゼンテーション引数とデバイス作成引数を設定する。
このコードでは、Form クラスから Vertices オブジェクトをインスタンス化し、モデルをディスプレイにレンダリングするためのフォーマットを設定する。
ディスプレイ フォーマットは、PresentParameters クラスのプロパティで設定する。フラグは、ハードウェア デバイスを使って、頂点をソフトウェアで処理するように設定している。
using Microsoft.DirectX.Direct3D;
.
.
.
namespace mySetUpDisplayForm
{
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
// Define vertex structure
.
.
.
}
public Vertices()
{
// Set up display form
}
public void OnCreateDevice(object sender, EventArgs e)
{
// Create and fill a vertex buffer to represent the Direct3D object
}
public bool InitializeGraphics()
{
try
{
// Create a PresentParameters object
PresentParameters presentParams = new PresentParameters();
// Don't run full screen
presentParams.Windowed = true;
// Discard the frames
presentParams.SwapEffect = SwapEffect.Discard;
// Instantiate a device
device = new Device(0,
DeviceType.Hardware,
this,
CreateFlags.SoftwareVertexProcessing,
presentParams);
device.DeviceCreated +=
new System.EventHandler(this.OnCreateDevice);
this.OnCreateDevice(device, null);
return true;
}
catch { return false; }
}
}
対象
© 2002 Microsoft Corporation. All rights reserved. Terms of use.