I am trying to initialize Direct 3d with this code:
Imports Microsoft.DirectX
Imports Microsoft.DirectX.Direct3D
Public Class Form1
Dim device As Device
Public Sub New()
InitializeComponent()
End Sub
Public Function init3d()
Try
Dim pparams As New PresentParameters
pparams.Windowed = True
pparams.SwapEffect = SwapEffect.Discard
device = New Device(0, DeviceType.Software, Me, CreateFlags.SoftwareVertexProcessing, pparams)
Return True
Catch ex As DirectXException
Return False
End Try
End Function
Private Sub render()
Me.device.Clear(ClearFlags.Target, Color.Blue, 1.0F, 0)
Me.device.BeginScene()
Me.device.EndScene()
Me.device.Present()
End Sub
Sub main()
If init3d() = False Then
MsgBox("Couldn't initialize graphics", MsgBoxStyle.OkCancel, "Error")
End If
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Me.render()
End Sub
End Class
when i try to debug i get this error:
quote:
Me.device.Clear(ClearFlags.Target, Color.Blue, 1.0F, 0)
Object reference not set to an instance of an object.