I'm trying to draw a simple square,
Public Sub OnCreateVertexBuffer(ByVal sender As Object, ByVal e As EventArgs)
Dim vb As VertexBuffer = CType(sender, VertexBuffer)
Dim vertices As CustomVertex.TransformedColored() = DirectCast(vb.Lock(0, 0), CustomVertex.TransformedColored())
vertices(0).X = 10
vertices(0).Y = 10
vertices(0).Z = 0.5F
vertices(0).Rhw = 1
vertices(0).Color = System.Drawing.Color.Black.ToArgb
vertices(1).X = 210
vertices(1).Y = 10
vertices(1).Z = 0.5F
vertices(1).Rhw = 1
vertices(1).Color = System.Drawing.Color.Blue.ToArgb
vertices(2).X = 10
vertices(2).Y = 210
vertices(2).Z = 0.5F
vertices(2).Rhw = 10
vertices(2).Color = System.Drawing.Color.White.ToArgb
vertices(3).X = 210
vertices(3).Y = 210
vertices(3).Z = 0.5F
vertices(3).Rhw = 10
vertices(3).Color = System.Drawing.Color.Red.ToArgb
vb.Unlock()
End Sub 'OnCreateVertexBuffer
Public Sub Render()
If dev Is Nothing Then
Return
End If
Try
dev.Clear(ClearFlags.Target, Color.Blue, 0, 0)
dev.BeginScene()
dev.StretchRectangle(BackSurface, New Rectangle(0, 0, 350, 263), BackBuffer, New Rectangle(0, 0, 350, 263), TextureFilter.None) 'this is where the surface is copied to the backbuffer
dev.SetStreamSource(0, vbuff, 0) 'set the source for drawing the vertices
dev.VertexFormat = CustomVertex.TransformedColored.Format 'the format of the vertex
dev.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 1) 'draw
dev.EndScene()
dev.Present()
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
End Sub
What am I doing wrong? It won't show the forth vertex.
Public Sub OnCreateVertexBuffer(ByVal sender As Object, ByVal e As EventArgs)
Dim vb As VertexBuffer = CType(sender, VertexBuffer)
Dim vertices As CustomVertex.TransformedColored() = DirectCast(vb.Lock(0, 0), CustomVertex.TransformedColored())
vertices(0).X = 10
vertices(0).Y = 10
vertices(0).Z = 0.5F
vertices(0).Rhw = 1
vertices(0).Color = System.Drawing.Color.Black.ToArgb
vertices(1).X = 210
vertices(1).Y = 10
vertices(1).Z = 0.5F
vertices(1).Rhw = 1
vertices(1).Color = System.Drawing.Color.Blue.ToArgb
vertices(2).X = 10
vertices(2).Y = 210
vertices(2).Z = 0.5F
vertices(2).Rhw = 10
vertices(2).Color = System.Drawing.Color.White.ToArgb
vertices(3).X = 210
vertices(3).Y = 210
vertices(3).Z = 0.5F
vertices(3).Rhw = 10
vertices(3).Color = System.Drawing.Color.Red.ToArgb
vb.Unlock()
End Sub 'OnCreateVertexBuffer
Public Sub Render()
If dev Is Nothing Then
Return
End If
Try
dev.Clear(ClearFlags.Target, Color.Blue, 0, 0)
dev.BeginScene()
dev.StretchRectangle(BackSurface, New Rectangle(0, 0, 350, 263), BackBuffer, New Rectangle(0, 0, 350, 263), TextureFilter.None) 'this is where the surface is copied to the backbuffer
dev.SetStreamSource(0, vbuff, 0) 'set the source for drawing the vertices
dev.VertexFormat = CustomVertex.TransformedColored.Format 'the format of the vertex
dev.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 1) 'draw
dev.EndScene()
dev.Present()
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
End Sub
What am I doing wrong? It won't show the forth vertex.