I am following this tutorial: http://www.vbgamer.com/tutorial.asp?ndx=12
I did the first one about Initializing d3d first...
Here is my code with the error message in the Render sub.
Imports Microsoft.DirectX
Imports Microsoft.DirectX.Direct3D
Public Class Form1
Dim Dev As Device = Nothing
Private VertBuff As VertexBuffer
Private strings As String = "ASD"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Init3ds() = False Then
MessageBox.Show("Awww.. No D3D for you!")
End If
Me.Show()
Do
Render()
Application.DoEvents()
Loop
End Sub
Public Function Init3ds() As Boolean
Try
Dim pParams As New PresentParameters()
pParams.Windowed = True
pParams.SwapEffect = SwapEffect.Discard
Dev = New Device(0, DeviceType.Hardware, Me, CreateFlags.SoftwareVertexProcessing, pParams)
Return True
MakeVerts()
Catch e As DirectXException
Return False
End Try
End Function
Private Sub Render()
Try
Dev.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0F, 0)
Dev.BeginScene()
Dev.SetStreamSource(0, VertBuff, 0)
Dev.VertexFormat = CustomVertex.TransformedColored.Format
Dev.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 1)
Dev.EndScene()
Dev.Present()
Catch ex As DirectXException
Debug.WriteLine(ex)
End Try
End Sub
Public Sub MakeVerts()
VertBuff = New VertexBuffer(GetType(CustomVertex.TransformedColored), 3, Dev, 0, CustomVertex.TransformedColored.Format, Pool.Default)
Dim verts As CustomVertex.TransformedColored() = CType(VertBuff.Lock(0, 0), CustomVertex.TransformedColored())
verts(0).X = 150
verts(0).Y = 50
verts(0).Z = 0.5F
verts(0).Rhw = 1
verts(0).Color = Color.Aqua.ToArgb
verts(1).X = 250
verts(1).Y = 250
verts(1).Z = 0.5F
verts(1).Rhw = 1
verts(1).Color = Color.Brown.ToArgb
verts(2).X = 50
verts(2).Y = 250
verts(2).Z = 0.5F
verts(2).Rhw = 1
verts(2).Color = Color.LightPink.ToArgb
VertBuff.Unlock()
End Sub
End Class