Page 1 of 1

DrawIndexedTriangleList

Posted: Sun Oct 15, 2006 8:58 am
by grunt
why isnt this working. It is supposed to draw a filled triangle, but just gives me an object reference not set to an instance of an object error. What gives?

Code: Select all

''' <summary>
        ''' Implements a filled triangle rather than a lined one.
        ''' </summary>
        ''' <param name="triangle"></param>
        ''' <remarks></remarks>
        Public Sub DrawSolidTri(ByVal triangle As Triangle3D)

            Dim indices(3) As UShort

            indices(0) = 0
            indices(1) = 1
            indices(2) = 2

            Dim verts1 As New Vertex3D
            Dim verts2 As New Vertex3D
            Dim verts3 As New Vertex3D
            Dim red As New Color(0, 255, 0, 0)

            verts1.Color = red
            verts2.Color = red
            verts3.Color = red

            verts1.Position = triangle.PointA
            verts2.Position = triangle.PointB
            verts3.Position = triangle.PointC

            Dim vertices(3) As Vertex3D

            vertices(0) = verts1
            vertices(1) = verts2
            vertices(2) = verts3

            device.VideoDriver.DrawIndexedTriangleList(vertices, 3, indices, 1)
        End Sub