和我一起入門Direct3D的VB.net編程
發表于:2007-06-30來源:作者:點擊數:
標簽:
我是個 VB 程序員 ,一直在做 數據庫 應用程序的 開發 ,做的時間長了就感覺很煩悶,很想換換口味,但苦于沒有學習時間和資料,恰巧看到CSDN上他人寫的學習經驗,我也就很快的入了門。好東西不敢獨享,隨著我學習的同時,把原來的C#程序改成了 vb .net的代碼
我是個
VB程序員,一直在做
數據庫應用程序的
開發,做的時間長了就感覺很煩悶,很想換換口味,但苦于沒有學習時間和資料,恰巧看到CSDN上他人寫的學習經驗,我也就很快的入了門。好東西不敢獨享,隨著我學習的同時,把原來的C#程序改成了
vb.net的代碼,但思路還是一樣的,僅供大家參考。
(感謝原文作者。原文:http://blog.csdn.net/ygrx/archive/2005/03/02/307781.aspx?Pending=true)
Imports Microsoft.DirectX
Imports Microsoft.DirectX.Direct3D
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows 窗體設計器生成的代碼 "
Public Sub New()
MyBase.New()
@#該調用是 Windows 窗體設計器所必需的。
InitializeComponent()
@#在 InitializeComponent() 調用之后添加任何初始化
Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.Opaque, True)
End Sub
@#窗體重寫 dispose 以清理組件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
@#Windows 窗體設計器所必需的
Private components As System.ComponentModel.IContainer
@#注意: 以下過程是 Windows 窗體設計器所必需的
@#可以使用 Windows 窗體設計器修改此過程。
@#不要使用代碼編輯器修改它。
<System.Diagnostics.De
buggerStepThrough()> Private Sub InitializeComponent()
@#
@#Form1
@#
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Name = "Form1"
Me.Text = "Form1"
End Sub
#End Region
阿游 發表于 2005-03-22 2:49 PM
Private device As Device
Public Sub InitializeGraphics()
@#設置參數
Dim presentParams As PresentParameters = New PresentParameters
presentParams.Windowed = True @#窗口模式
presentParams.SwapEffect = SwapEffect.Discard @#交換
@#創建設備
device = New Device(0, DeviceType.Hardware, Me, CreateFlags.SoftwareVertexProcessing, presentParams)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
InitializeGraphics()
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
device.Clear(ClearFlags.Target, System.Drawing.Color.CadetBlue, 1.0F, 0)
Dim verts(2) As CustomVertex.TransformedColored
verts(0).Position = New Vector4(Me.Width / 2.0F, 50.0F, 0.5F, 1.0F)
verts(0).Color = System.Drawing.Color.Aqua.ToArgb()
verts(1).Position = New Vector4(Me.Width - Me.Width / 5.0F, Me.Height - Me.Height / 5.0F, 0.5F, 1.0F)
verts(1).Color = System.Drawing.Color.Black.ToArgb()
verts(2).Position = New Vector4(Me.Width / 5.0F, Me.Height - Me.Height / 5.0F, 0.5F, 1.0F)
verts(2).Color = System.Drawing.Color.Purple.ToArgb()
device.BeginScene()
device.VertexFormat = CustomVertex.TransformedColored.Format
device.DrawUserPrimitives(PrimitiveType.TriangleList, 1, verts)
device.EndScene()
device.Present()
Me.Invalidate()
End Sub
End Class
原文轉自:http://www.kjueaiud.com