Device 클래스
업데이트: 2007년 11월
장면에 있는 모든 그래픽 개체의 부모 개체입니다.
네임스페이스: 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
public class Device implements IDisposable
설명
장치에서는 기본 형식 기반 렌더링을 수행하고 리소스를 만들 뿐 아니라 시스템 수준 변수를 처리하며 색상표를 가져오고 설정합니다.
예제
다음 코드 예제에서는 장치를 만듭니다.
Public Class Form1
Inherits Form
' Set global variables for this project.
Private device As Device = Nothing
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
' Set up presentation parameters and create the Direct3D
' device.
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()
'Render scene objects, if desired.
'End the scene.
device.EndScene()
device.Present()
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
' Render on painting.
Me.Render()
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
' Handle the ESC key being pressed.
Me.Close()
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
{
// 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";
}
public bool 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);
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 scene objects, if desired.
//End the scene.
device.EndScene();
device.Present();
}
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
// Render on painting.
this.Render();
}
protected override void 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>
static void 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 Framework 시스템 요구 사항을 참조하십시오.
버전 정보
.NET Compact Framework
3.5, 2.0에서 지원
참고 항목
참조
Microsoft.WindowsMobile.DirectX.Direct3D 네임스페이스