Device クラスとは? わかりやすく解説

Device クラス

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

名前空間: Microsoft.WindowsMobile.DirectX.Direct3D
アセンブリ: Microsoft.WindowsMobile.DirectX (microsoft.windowsmobile.directx.dll 内)
構文構文

解説解説
使用例使用例

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

Public Class Form1
    Inherits Form
    ' Global variables for this project.
    Private device As Device = Nothing
    ' Rendering device.
    Public Sub New()
        ' Set the initial size and caption of the form.
        Me.ClientSize = New System.Drawing.Size(400,
 300)
        Me.Text = "D3D Tutorial 01: CreateDevice"

    End Sub 'New


    Public Function InitializeGraphics() As
 Boolean
        Try
            ' Setup Direct3D.
            Dim presentParams As New
 PresentParameters()
            presentParams.Windowed = True
            presentParams.SwapEffect = SwapEffect.Discard
            device = New Device(0, DeviceType.Default, Me,
 CreateFlags.None, presentParams)
            Return True
        Catch
            Return False
        End Try

    End Function

    Private Sub Render()
        If device Is Nothing
 Then
            Return
        End If
        'Clear the backbuffer to a blue color. 
        device.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0F, 0)
        'Begin the scene
        device.BeginScene()

        'Rendering of scene objects can happen here.
        'End the scene
        device.EndScene()
        device.Present()

    End Sub

    Protected Overrides Sub
 OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
        Me.Render()
        ' Render on painting.
    End Sub

    Protected Overrides Sub
 OnKeyPress(ByVal e As System.Windows.Forms.KeyPressEventArgs)
        If Fix(System.Convert.ToByte(e.KeyChar)) = Fix(System.Windows.Forms.Keys.Escape)
 Then
            Me.Close() ' Esc was pressed
        End If

    End Sub

    Shared Sub Main()

        Dim DeviceForm As New
 Form1()
        Try
            If Not DeviceForm.InitializeGraphics()
 Then
                ' Initialize Direct3D
                MsgBox("Could not initialize Direct3D.  This tutorial
 will exit.")
                Return
            End If
            DeviceForm.Show()

            'While the form is still valid, render and process messages
            'While DeviceForm.Created
            '    DeviceForm.Render()
            '    Application.DoEvents()
            'End While
        Finally
            DeviceForm.Dispose()
        End Try

    End Sub
End Class
public class CreateDevice : Form
{
    // Our global variables for this project
    Device device = null; // Our rendering device

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

    public bool InitializeGraphics()
    {
        try
        {
            // Now let's setup our D3D stuff
            PresentParameters presentParams = new PresentParameters();
            presentParams.Windowed = true;
            presentParams.SwapEffect = SwapEffect.Discard;
            device = new Device(0, DeviceType.Default, this,
 CreateFlags.None, presentParams);
            return true;
        }
        catch (DirectXException)
        {
            return false;
        }
    }
    private void 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 of scene objects can happen here

        //End the scene
        device.EndScene();
        device.Present();
    }
    protected override void OnPaint(System.Windows.Forms.PaintEventArgs
 e)
    {
        this.Render(); // Render on painting
    }
    protected override void OnKeyPress(System.Windows.Forms.KeyPressEventArgs
 e)
    {
        if ((int)(byte)e.KeyChar == (int)System.Windows.Forms.Keys.Escape)
            this.Close(); // Esc was pressed
    }

    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    static void Main()
    {

        using (CreateDevice DeviceForm = new
 CreateDevice())
        {
            if (!DeviceForm.InitializeGraphics()) //
 Initialize Direct3D
            {
                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.BaseMesh
    Microsoft.WindowsMobile.DirectX.Direct3D.Device
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Device クラス」の関連用語

Device クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Device クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS