Share via


Device クラス

[このドキュメントはプレビュー版であり、後のリリースで変更されることがあります。 空白のトピックは、プレースホルダーとして挿入されています。]

シーン内のすべてのグラフィカル オブジェクトの親オブジェクト。

名前空間:  Microsoft.WindowsMobile.DirectX.Direct3D
アセンブリ:  Microsoft.WindowsMobile.DirectX (Microsoft.WindowsMobile.DirectX.dll 内)

構文

'宣言
Public Class Device _
    Implements IDisposable
'使用
Dim instance As Device
public class Device : IDisposable
public ref class Device : IDisposable
type Device =  
    class
        interface IDisposable
    end

解説

デバイスは、プリミティブ ベースのレンダリング、リソースの作成、システムレベル変数の処理、およびパレットの取得と設定を行います。

デバイスを作成するコード例を次に示します。

PublicClass Form1
    Inherits Form
    ' Set global variables for this project.Private device As Device = NothingPublicSubNew()
        ' Set the initial size and caption of the form.Me.ClientSize = New System.Drawing.Size(400, 300)
        Me.Text = "D3D Tutorial 01: CreateDevice"EndSub 'NewPublicFunction InitializeGraphics() AsBooleanTry            ' Set up presentation parameters and create the Direct3D            ' device.Dim presentParams AsNew PresentParameters()
            presentParams.Windowed = True
            presentParams.SwapEffect = SwapEffect.Discard
            device = New Device(0, DeviceType.Default, Me, CreateFlags.None, presentParams)
            ReturnTrueCatchReturnFalseEndTryEndFunctionPrivateSub Render()
        If device IsNothingThenReturnEndIf        'Clear the backbuffer to a blue color. 
        device.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0F, 0)
        'Begin the scene.
        device.BeginScene()

        'Render scene objects, if desired.        'End the scene.
        device.EndScene()
        device.Present()

    EndSubProtectedOverridesSub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
        ' Render on painting.Me.Render()
    EndSubProtectedOverridesSub OnKeyPress(ByVal e As System.Windows.Forms.KeyPressEventArgs)
        If Fix(System.Convert.ToByte(e.KeyChar)) = Fix(System.Windows.Forms.Keys.Escape) Then            ' Handle the ESC key being pressed.Me.Close()
        EndIfEndSubSharedSub Main()

        Dim DeviceForm AsNew Form1()
        TryIfNot DeviceForm.InitializeGraphics() Then                ' Initialize Direct3D.
                MsgBox("Could not initialize Direct3D.  This tutorial will exit.")
                ReturnEndIf
            DeviceForm.Show()

            'While the form is still valid, render and process messages.            'While DeviceForm.Created            '    DeviceForm.Render()            '    Application.DoEvents()            'End WhileFinally
            DeviceForm.Dispose()
        EndTryEndSubEndClass
publicclass CreateDevice : Form
{
    // Set global variables for this project.
    Device device = null;

    public CreateDevice()
    {
        // Set the initial size of the form.this.ClientSize = new System.Drawing.Size(400, 300);
        // Set the caption for the form.this.Text = "D3D Tutorial 01: CreateDevice";
    }

    publicbool InitializeGraphics()
    {
        try
        {
            // Set up presentation parameters and create the // Direct3D device.
            PresentParameters presentParams = new PresentParameters();
            presentParams.Windowed = true;
            presentParams.SwapEffect = SwapEffect.Discard;
            device = new Device(0, DeviceType.Default, this, CreateFlags.None, presentParams);
            returntrue;
        }
        catch (DirectXException)
        {
            returnfalse;
        }
    }
    privatevoid Render()
    {
        if (device == null)
            return;

        //Clear the backbuffer to a blue color. 
        device.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0f, 0);
        //Begin the scene.
        device.BeginScene();

        // Rendering scene objects, if desired.//End the scene.
        device.EndScene();
        device.Present();
    }
    protectedoverridevoid OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        // Render on painting.this.Render();
    }
    protectedoverridevoid OnKeyPress(System.Windows.Forms.KeyPressEventArgs e)
    {
        if ((int)(byte)e.KeyChar == (int)System.Windows.Forms.Keys.Escape)
            // Handle the ESC key being pressed.this.Close();
    }

    /// <Summary>/// The main entry point for the application./// </Summary>staticvoid Main()
    {

        using (CreateDevice DeviceForm = new CreateDevice())
        {
            // Initialize Direct3D.if (!DeviceForm.InitializeGraphics())
            {
                MessageBox.Show("Could not initialize Direct3D.  This tutorial will exit.");
                return;
            }
            DeviceForm.Show();

            // While the form is still valid, render and process messages.// while (DeviceForm.Created)//{
                DeviceForm.Render();
                Application.DoEvents();
            //}
        }
    }
}

継承階層

System.Object
  Microsoft.WindowsMobile.DirectX.Direct3D.Device

スレッド セーフ

この型のすべてのパブリック static (Visual Basic では Shared) メンバーは、スレッド セーフです。 インスタンス メンバーの場合は、スレッド セーフであるとは限りません。

プラットフォーム

Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。 サポートされているバージョンについては、「.NET フレームワークのシステム要件」を参照してください。

バージョン情報

.NET Compact Framework

サポート対象 : 3.5、2.0

参照

参照

Device メンバー

Microsoft.WindowsMobile.DirectX.Direct3D 名前空間

その他の技術情報

.NET Compact Framework でモバイル Direct3D プログラミング