'Note that it will return an array of 3 because that's how many we specified in the vertex buffer constructor.
Vertices(0) = New CustomVertex.TransformedColored(200.0F, 150.0F, 0.0F, 1.0F, &HC0C0C0) 'X,Y,Z,RHW, and color.
'X and Y are self-explanatory at the moment: they are the coordinates of the vertex on the form.
'I just set Z to 0.
'RHW: Regularly Holds (W)one... yeah, it really stands for "Reciprocal of Homogenous W"... what's W?
'A coefficient in some mathematical operation, probably.
'Color is in the &HRRGGBB format: the first two hex digits control the blue in the color, 3 and 4 control the green, and
'5 and 6 control the red. Of course, you can always use Color.ToArgb() to get a color.
'I figure I can do all of this inline since I'm just setting values for the vertices.
Vertices(1).X = 200.0F : Vertices(1).Y = 250.0F : Vertices(1).Rhw = 1.0F : Vertices(1).Color = &HFF
Vertices(2).X = 100.0F : Vertices(2).Y = 150.0F : Vertices(2).Rhw = 1.0F : Vertices(2).Color = &HFFFF00
'Now, you can't just place vertices anywhere: you have to place them clockwise.
'Specifically, you have to place them so that their 'normal vector' or the 'face' points into the screen.
'The normal vector is a vector that lies perpendicular to the object. Since our triangle (and all triangles)
'is a 2D object, the normal can be on one side or the other. In order to determine which side is the 'face' or the
'normal', we use the right hand rule. Put your right wrist at the first vertex of the triangle. Place the tips of the
'four big fingers of your right hand (I hope you have four) at the second vertex (or at least, in its direction).
'Now, see if you can, while closing the open palm of your right hand into a fist, point those four fingers to the
'direction of the third vertex. If you can do this, then the direction of your thumb indicates the normal.
'In this case, if you could do this, then you didn't draw your triangle correctly: try switching the last two vertices.
'If the last vertex is on the knuckle side of your hand, you need to flip your hand over to get the thumb to point in the
'direction of the normal vector... but save your wrist: this just means the normal vector is in the opposite direction
'of your thumb... and in this case, if your thumb is on top and the last point is on your knuckle side, then your points
'are drawn correctly. If you have decent visualization of 3D, then you only need to figure out which side you have to
'be on the triangle for the points to appear clockwise - in this case, the direction that you are looking is the direction
'of the normal vector.
Vertices(3) = New CustomVertex.TransformedColored(200.0F, 50.0F, 0.0F, 1.0F, &HFF0000)
Vertices(4) = New CustomVertex.TransformedColored(300.0F, 150.0F, 0.0F, 1.0F, &HFF00)