Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

  • *Experts*
Posted

Can you post the answer so that others can get some help from it?

 

-nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...