I was brainstorming to find a way to render a line in DX8 for a various purposes and I found that DX8 didn’t have a method to render a line with a width. It’ll always have a width of I think 1 pixel. So I googled and found the only way this was possible is by rendering a Quadrilateral with a length and a width. So here is my function for this:
Public Sub RenderLine(ByVal x As Long, ByVal y As Long, width As Long, ByVal length As Long, ByVal Colour As Long, Optional ByVal Horizontal As Boolean = True) Dim linev(0 To 3) As TLVERTEX, i As Long ' THIS PROCEDURE DOES NOT USE D3DPT_LINESTRIP. It USES QUADS TO SIMULATE A LINE. For i = 0 To 3 linev(i).color = dx8Colour(colour, -1) linev(i).RHW = 1 Next If Horizontal Then linev(0).x = x linev(0).y = y linev(1).x = x + width linev(1).y = y linev(2).x = x linev(2).y = y + length linev(3).x = x + width linev(3).y = y + length Else linev(0).x = x linev(0).y = y linev(1).x = x + length linev(1).y = y linev(2).x = x linev(2).y = y + width linev(3).x = x + length linev(3).y = y + width End If Call D3DDevice8.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, linev(0), FVF_Size) End Sub
This accepts a x and y coordinate as the start position of the “line” and a length for the line and it’s width. A color can also be given. The last variable is for determining how to render the line. Along the x axis or the y axis.
One problem to this that you can’t (or I don’t think you can) render a line diagonally.
If you can’t understand a specific part of the above code post below and I’ll be glad to help.