type vertice x as integer y as integer side as integer ' this value is either -1,0, or 1... -1 means left side, 0 means both sides, 1 means right side (both sides is a top or bottom point) NLP as integer ' the next left side point ...most points will only have a value in one of these, depending if it is a left or right point NRP as integer ' the next right side point Lslp as double ' this is the slope from this point towards the next point ON THE LEFT SIDE! ...most points will only have a value in one of these, depending if it is a left or right point Rslp as double ' this is the slope from this point towards the next point ON THE RIGHT SIDE!end type

NumOfPoints = Points(0).x''sort the array of points, from top to bottom, and left to right' dim as integer exchange = 1, passnum = NumOfPoints - 1 while passnum > 0 and exchange = 1 exchange = 0 for i as integer = 1 to passnum if points(i).y > points(i+1).y then exchange = 1 swap points(i), points(i+1) end if

' if the Y values are same, then sort based on x values... if points(i).y = points(i+1).y then if points(i).x > points(i+1).x then exchange = 1 swap points(i), points(i+1) end if end if next i passnum -= 1 wend

'' calc main left/right dividing slope...' dim as integer TLP, TRP dim as double MainSlope, CurSlope MainSlope = (points(1).x - points(NumOfPoints).x) / (points(1).y - points(NumOfPoints).y) '<--- this is the slope of the line from top to bottom points

'' compare the Main Slope to the slope to each of the other points to determine if each point is 'left' or 'right' for p as integer = 2 to NumOfPoints-1 CurSlope = (points(1).x - points(p).x) / (points(1).y - points(p).y) if CurSlope < MainSlope then points(p).side = -1 '<---left side else points(p).side = 1 '<---right side end if next p

TLP = 1 ' set top Left Point to the first point TRP = 1 ' set Top Right Point same as Top Left Point points(1).side = 0 ' set first point side to 0 (means is on BOTH sides)

' check for same y value of first two points if points(1).y = points(2).y then points(2).side = 1 ' set second point to RIGHT side only points(1).side = -1 ' set first point to LEFT side only, 0 means BOTH sides TRP = 2 ' set Top Right Point to the second point end if

' NOW, figure out the slopes of each point ot the next point on same side! ' This is where we figure out all the slopes, from one point to the next in line, for each side ' we will need these as we start filling the polygon and come to the next point/corner where we ' will change the slope value that we add to the left side X-value dim as integer curleftpoint = TLP, currightpoint = TRP, nextLeft, nextRight

' find all the left points, calc each slope do ' find next left point nextLeft = curleftpoint do nextLeft += 1 loop while points(nextLeft).side > 0

' got the next left, now calc slope to it from current left points(curleftpoint).Lslp = (points(curleftpoint).x - points(nextLeft).x) / (points(curleftpoint).y - points(nextLeft).y) ' save this next point points(curleftpoint).NLP = nextLeft curleftpoint = nextLeft loop while points(nextleft).side <> 0 'until at bottom point

' find all the right points, calc each slope do ' find next right point nextRight = currightpoint do nextRight += 1 loop while points(nextRight).side < 0

' got the next right, now calc slope to it from current right points(currightpoint).Rslp = (points(currightpoint).x - points(nextRight).x) / (points(currightpoint).y - points(nextRight).y) ' save this next point points(currightpoint).NRP = nextRight currightpoint = nextRight loop while points(nextRight).side <> 0 'until at bottom point

' ok, now we got a sorted array of points, each identified as to which 'side' they are on, with the slopes from one point to the next point on the same side stored' lets determine how many yvalues there will be in total... dim as integer NumOfYvalues = points(NumOfPoints).y - points(1).y + 1

' set the current point for each side dim as integer CLP = TLP, CRP = TRP

' this is where the magic happens.... ' Lx and Rx are the current x-values for each side ' points(CLP).Lslp and points(CRP).Rslp are the slopes (change in X) for the current point on each side (CLP=Current Left Point, CRP=Current Right Point) ' Lslp = Left Slope, Rslp = Right Slope... these are DOUBLES, not integers ' ' determine starting address of the ROW for top most Y value (points(1).y) ' for direct screen access ScreenInfo w, h, , bypp, pitch Dim buffer As Any Ptr = ScreenPtr() Dim As Any Ptr row = buffer + (pitch * points(1).y) Dim As UInteger Ptr pixel

for yvalue as integer = points(1).y + 1 to points(NumOfPoints).y 'iterate through all the yvalues ' calc the x-value for this y value for both Left and Right Lx += points(CLP).Lslp : Rx += points(CRP).Rslp

' increment the row address (y-value) each time... row += pitch

' calc the x-value for this y value for both Left and Right Lx += points(CLP).Lslp : Rx += points(CRP).Rslp

' calc starting x-value address pixel = row + (int(Lx) * 4)

' draw the line between the to xvalues at this yvalue 'line (int(Lx), yvalue) - (int(Rx), yvalue), rgb(0,255,0)

' check to see if reached next left/right points... ' change current left point to the next left point! if yvalue >= points(points(CLP).NLP).y then CLP = points(CLP).NLP ' change current right point to the next right point! if yvalue >= points(points(CRP).NRP).y then CRP = points(CRP).NRP

type vertice x as integer y as integer side as integer ' this value is either -1,0, or 1... -1 means left side, 0 means both sides, 1 means right side (both sides is a top or bottom point) NLP as integer ' the next left side point ...most points will only have a value in one of these, depending if it is a left or right point NRP as integer ' the next right side point Lslp as double ' this is the slope from this point towards the next point ON THE LEFT SIDE! ...most points will only have a value in one of these, depending if it is a left or right point Rslp as double ' this is the slope from this point towards the next point ON THE RIGHT SIDE!end type

NumOfPoints = Points(0).x''sort the array of points, from top to bottom, and left to right' dim as integer exchange = 1, passnum = NumOfPoints - 1 while passnum > 0 and exchange = 1 exchange = 0 for i as integer = 1 to passnum if points(i).y > points(i+1).y then exchange = 1 swap points(i), points(i+1) end if

' if the Y values are same, then sort based on x values... if points(i).y = points(i+1).y then if points(i).x > points(i+1).x then exchange = 1 swap points(i), points(i+1) end if end if next i passnum -= 1 wend

'' calc main left/right dividing slope...' dim as integer TLP, TRP dim as double MainSlope, CurSlope MainSlope = (points(1).x - points(NumOfPoints).x) / (points(1).y - points(NumOfPoints).y) '<--- this is the slope of the line from top to bottom points

'' compare the Main Slope to the slope to each of the other points to determine if each point is 'left' or 'right' for p as integer = 2 to NumOfPoints-1 CurSlope = (points(1).x - points(p).x) / (points(1).y - points(p).y) if CurSlope < MainSlope then points(p).side = -1 '<---left side else points(p).side = 1 '<---right side end if next p

TLP = 1 ' set top Left Point to the first point TRP = 1 ' set Top Right Point same as Top Left Point points(1).side = 0 ' set first point side to 0 (means is on BOTH sides)

' check for same y value of first two points if points(1).y = points(2).y then points(2).side = 1 ' set second point to RIGHT side only points(1).side = -1 ' set first point to LEFT side only, 0 means BOTH sides TRP = 2 ' set Top Right Point to the second point end if

' NOW, figure out the slopes of each point ot the next point on same side! ' This is where we figure out all the slopes, from one point to the next in line, for each side ' we will need these as we start filling the polygon and come to the next point/corner where we ' will change the slope value that we add to the left side X-value dim as integer curleftpoint = TLP, currightpoint = TRP, nextLeft, nextRight

' find all the left points, calc each slope do ' find next left point nextLeft = curleftpoint do nextLeft += 1 loop while points(nextLeft).side > 0

' got the next left, now calc slope to it from current left points(curleftpoint).Lslp = (points(curleftpoint).x - points(nextLeft).x) / (points(curleftpoint).y - points(nextLeft).y) ' save this next point points(curleftpoint).NLP = nextLeft curleftpoint = nextLeft loop while points(nextleft).side <> 0 'until at bottom point

' find all the right points, calc each slope do ' find next right point nextRight = currightpoint do nextRight += 1 loop while points(nextRight).side < 0

' got the next right, now calc slope to it from current right points(currightpoint).Rslp = (points(currightpoint).x - points(nextRight).x) / (points(currightpoint).y - points(nextRight).y) ' save this next point points(currightpoint).NRP = nextRight currightpoint = nextRight loop while points(nextRight).side <> 0 'until at bottom point

' ok, now we got a sorted array of points, each identified as to which 'side' they are on, with the slopes from one point to the next point on the same side stored' lets determine how many yvalues there will be in total... dim as integer NumOfYvalues = points(NumOfPoints).y - points(1).y + 1

' set the current point for each side dim as integer CLP = TLP, CRP = TRP

' this is where the magic happens.... ' Lx and Rx are the current x-values for each side ' points(CLP).Lslp and points(CRP).Rslp are the slopes (change in X) for the current point on each side (CLP=Current Left Point, CRP=Current Right Point) ' Lslp = Left Slope, Rslp = Right Slope... these are DOUBLES, not integers ' ' determine starting address of the ROW for top most Y value (points(1).y) ' for direct screen access ScreenInfo w, h, , bypp, pitch Dim buffer As Any Ptr = ScreenPtr() Dim As Any Ptr row = buffer + (pitch * points(1).y) ' address of the row where the top Y-value is Dim As UInteger Ptr pixel

for yvalue as integer = points(1).y + 1 to points(NumOfPoints).y 'iterate through all the yvalues ' calc the x-value for this y value for both Left and Right Lx += points(CLP).Lslp : Rx += points(CRP).Rslp

' increment the row address (y-value) each time... row += pitch

' calc the x-value for this y value for both Left and Right Lx += points(CLP).Lslp : Rx += points(CRP).Rslp

' check to see if reached next left/right points... ' change current left point to the next left point! if yvalue >= points(points(CLP).NLP).y then CLP = points(CLP).NLP ' change current right point to the next right point! if yvalue >= points(points(CRP).NRP).y then CRP = points(CRP).NRP

type vertice x as integer y as integer side as integer ' this value is either -1,0, or 1... -1 means left side, 0 means both sides, 1 means right side (both sides is a top or bottom point) NLP as integer ' the next left side point ...most points will only have a value in one of these, depending if it is a left or right point NRP as integer ' the next right side point Lslp as double ' this is the slope from this point towards the next point ON THE LEFT SIDE! ...most points will only have a value in one of these, depending if it is a left or right point Rslp as double ' this is the slope from this point towards the next point ON THE RIGHT SIDE!end type

NumOfPoints = Points(0).x''sort the array of points, from top to bottom, and left to right' dim as integer exchange = 1, passnum = NumOfPoints - 1 while passnum > 0 and exchange = 1 exchange = 0 for i as integer = 1 to passnum if points(i).y > points(i+1).y then exchange = 1 swap points(i), points(i+1) end if

' if the Y values are same, then sort based on x values... if points(i).y = points(i+1).y then if points(i).x > points(i+1).x then exchange = 1 swap points(i), points(i+1) end if end if next i passnum -= 1 wend

'' calc main left/right dividing slope...' dim as integer TLP, TRP dim as double MainSlope, CurSlope MainSlope = (points(1).x - points(NumOfPoints).x) / (points(1).y - points(NumOfPoints).y) '<--- this is the slope of the line from top to bottom points

'' compare the Main Slope to the slope to each of the other points to determine if each point is 'left' or 'right' for p as integer = 2 to NumOfPoints-1 CurSlope = (points(1).x - points(p).x) / (points(1).y - points(p).y) if CurSlope < MainSlope then points(p).side = -1 '<---left side else points(p).side = 1 '<---right side end if next p

TLP = 1 ' set top Left Point to the first point TRP = 1 ' set Top Right Point same as Top Left Point points(1).side = 0 ' set first point side to 0 (means is on BOTH sides)

' check for same y value of first two points if points(1).y = points(2).y then points(2).side = 1 ' set second point to RIGHT side only points(1).side = -1 ' set first point to LEFT side only, 0 means BOTH sides TRP = 2 ' set Top Right Point to the second point end if

' NOW, figure out the slopes of each point ot the next point on same side! ' This is where we figure out all the slopes, from one point to the next in line, for each side ' we will need these as we start filling the polygon and come to the next point/corner where we ' will change the slope value that we add to the left side X-value dim as integer curleftpoint = TLP, currightpoint = TRP, nextLeft, nextRight

' find all the left points, calc each slope do ' find next left point nextLeft = curleftpoint do nextLeft += 1 loop while points(nextLeft).side > 0

' got the next left, now calc slope to it from current left points(curleftpoint).Lslp = (points(curleftpoint).x - points(nextLeft).x) / (points(curleftpoint).y - points(nextLeft).y) ' save this next point points(curleftpoint).NLP = nextLeft curleftpoint = nextLeft loop while points(nextleft).side <> 0 'until at bottom point

' find all the right points, calc each slope do ' find next right point nextRight = currightpoint do nextRight += 1 loop while points(nextRight).side < 0

' got the next right, now calc slope to it from current right points(currightpoint).Rslp = (points(currightpoint).x - points(nextRight).x) / (points(currightpoint).y - points(nextRight).y) ' save this next point points(currightpoint).NRP = nextRight currightpoint = nextRight loop while points(nextRight).side <> 0 'until at bottom point

' ok, now we got a sorted array of points, each identified as to which 'side' they are on, with the slopes from one point to the next point on the same side stored' lets determine how many yvalues there will be in total... dim as integer NumOfYvalues = points(NumOfPoints).y - points(1).y + 1

' set the current point for each side dim as integer CLP = TLP, CRP = TRP

' this is where the magic happens.... ' Lx and Rx are the current x-values for each side ' points(CLP).Lslp and points(CRP).Rslp are the slopes (change in X) for the current point on each side (CLP=Current Left Point, CRP=Current Right Point) ' Lslp = Left Slope, Rslp = Right Slope... these are DOUBLES, not integers ' ' determine starting address for top most Y value (points(1).y)

for yvalue as integer = points(1).y + 1 to points(NumOfPoints).y 'iterate through all the yvalues ' calc the x-value for this y value for both Left and Right Lx += points(CLP).Lslp : Rx += points(CRP).Rslp

' increment the row address (y-value) each time... row += pitch

' calc the x-value for this y value for both Left and Right ' Lx += points(CLP).Lslp : Rx += points(CRP).Rslp (you did this twice ???????)

' check to see if reached next left/right points... ' change current left point to the next left point! if yvalue >= points(points(CLP).NLP).y then CLP = points(CLP).NLP ' change current right point to the next right point! if yvalue >= points(points(CRP).NRP).y then CRP = points(CRP).NRPscreenunlock sleep 1 next yvalue

(2) currently it writes each pixel value in a line (albeit very fast), a faster way would be to use the mem_clear or mem_copy functions (forgot their actual names...), but this will probably be unnecessary.

I will now put it into the speed test program so we can compare apples to apples... need to beat the 500 fps you were getting!

type vertice x as integer y as integer side as integer ' this value is either -1,0, or 1... -1 means left side, 0 means both sides, 1 means right side (both sides is a top or bottom point) NLP as integer ' the next left side point ...most points will only have a value in one of these, depending if it is a left or right point NRP as integer ' the next right side point Lslp as double ' this is the slope from this point towards the next point ON THE LEFT SIDE! ...most points will only have a value in one of these, depending if it is a left or right point Rslp as double ' this is the slope from this point towards the next point ON THE RIGHT SIDE!end type

NumOfPoints = Points(0).x''sort the array of points, from top to bottom, and left to right' dim as integer exchange = 1, passnum = NumOfPoints - 1 while passnum > 0 and exchange = 1 exchange = 0 for i as integer = 1 to passnum if points(i).y > points(i+1).y then exchange = 1 swap points(i), points(i+1) end if

' if the Y values are same, then sort based on x values... if points(i).y = points(i+1).y then if points(i).x > points(i+1).x then exchange = 1 swap points(i), points(i+1) end if end if next i passnum -= 1 wend

'' calc main left/right dividing slope...' dim as integer TLP, TRP dim as double MainSlope, CurSlope MainSlope = (points(1).x - points(NumOfPoints).x) / (points(1).y - points(NumOfPoints).y) '<--- this is the slope of the line from top to bottom points

'' compare the Main Slope to the slope to each of the other points to determine if each point is 'left' or 'right' for p as integer = 2 to NumOfPoints-1 CurSlope = (points(1).x - points(p).x) / (points(1).y - points(p).y) if CurSlope < MainSlope then points(p).side = -1 '<---left side else points(p).side = 1 '<---right side end if next p

TLP = 1 ' set top Left Point to the first point TRP = 1 ' set Top Right Point same as Top Left Point points(1).side = 0 ' set first point side to 0 (means is on BOTH sides)

' check for same y value of first two points if points(1).y = points(2).y then points(2).side = 1 ' set second point to RIGHT side only points(1).side = -1 ' set first point to LEFT side only, 0 means BOTH sides TRP = 2 ' set Top Right Point to the second point end if

' NOW, figure out the slopes of each point ot the next point on same side! ' This is where we figure out all the slopes, from one point to the next in line, for each side ' we will need these as we start filling the polygon and come to the next point/corner where we ' will change the slope value that we add to the left side X-value dim as integer curleftpoint = TLP, currightpoint = TRP, nextLeft, nextRight

' find all the left points, calc each slope do ' find next left point nextLeft = curleftpoint do nextLeft += 1 loop while points(nextLeft).side > 0

' got the next left, now calc slope to it from current left points(curleftpoint).Lslp = (points(curleftpoint).x - points(nextLeft).x) / (points(curleftpoint).y - points(nextLeft).y) ' save this next point points(curleftpoint).NLP = nextLeft curleftpoint = nextLeft loop while points(nextleft).side <> 0 'until at bottom point

' find all the right points, calc each slope do ' find next right point nextRight = currightpoint do nextRight += 1 loop while points(nextRight).side < 0

' got the next right, now calc slope to it from current right points(currightpoint).Rslp = (points(currightpoint).x - points(nextRight).x) / (points(currightpoint).y - points(nextRight).y) ' save this next point points(currightpoint).NRP = nextRight currightpoint = nextRight loop while points(nextRight).side <> 0 'until at bottom point

' ok, now we got a sorted array of points, each identified as to which 'side' they are on, with the slopes from one point to the next point on the same side stored' lets determine how many yvalues there will be in total... dim as integer NumOfYvalues = points(NumOfPoints).y - points(1).y + 1

' set the current point for each side dim as integer CLP = TLP, CRP = TRP

' this is where the magic happens.... ' Lx and Rx are the current x-values for each side ' points(CLP).Lslp and points(CRP).Rslp are the slopes (change in X) for the current point on each side (CLP=Current Left Point, CRP=Current Right Point) ' Lslp = Left Slope, Rslp = Right Slope... these are DOUBLES, not integers ' ' for direct screen access Dim As Integer w, h, bypp, pitch ScreenInfo w, h, , bypp, pitch Dim buffer As Any Ptr = ScreenPtr() Dim As Any Ptr row = buffer + (pitch * Cint(points(1).y)) Dim As UInteger Ptr pixel

for yvalue as integer = points(1).y + 1 to points(NumOfPoints).y 'iterate through all the yvalues ' calc the x-value for this y value for both Left and Right Lx += points(CLP).Lslp : Rx += points(CRP).Rslp

screenlock ' OLD SLOW LINE DRAW METHOD ' ' draw the line between the to xvalues at this yvalue 'line (int(Lx), yvalue) - (int(Rx), yvalue), rgb(0,255,0) ' -------------------------------------------------------

' check to see if reached next left/right points... ' change current left point to the next left point! if yvalue >= points(points(CLP).NLP).y then CLP = points(CLP).NLP ' change current right point to the next right point! if yvalue >= points(points(CRP).NRP).y then CRP = points(CRP).NRP sleep 1 next yvalue

Dang nabbit! for some reason my system has some sort of a 'speed limit' on it - I can't get higher than 60 fps (is it somehow tied to vsync?) Even when I try to run the previous speed test where I got 300+ fps, same exact program now gets 60-65 fps...

here is the new speed test code - there is a variable called 'Tester' which you change from either 0 or 1 depending on which way you want to test, also removed the randomize timer so that both ways were using the same random test data... I get 60 fps on both ways so can't really test... wanna try on your systems?

Dodi, do you have any ideas why my fps would be limited? I have encountered this before but there seems to be no rhyme or reason to when/how it happens....

Just restarted puter, and had only FB running, and still limited - tested with different sleep values: sleep 1 - 11 ALL produce same result of 65, sleep 12 gets about 55... this is frustraing... going to make a standalone exe and see if problem follows..

speed limiting bug does follow program into its standalone EXE form... is it my system settings? wtf?!

type vertice x as integer y as integer side as integer ' this value is either -1,0, or 1... -1 means left side, 0 means both sides, 1 means right side (both sides is a top or bottom point) NLP as integer ' the next left side point ...most points will only have a value in one of these, depending if it is a left or right point NRP as integer ' the next right side point Lslp as double ' this is the slope from this point towards the next point ON THE LEFT SIDE! ...most points will only have a value in one of these, depending if it is a left or right point Rslp as double ' this is the slope from this point towards the next point ON THE RIGHT SIDE!end type

NumOfPoints = Points(0).x''sort the array of points, from top to bottom, and left to right' dim as integer exchange = 1, passnum = NumOfPoints - 1 while passnum > 0 and exchange = 1 exchange = 0 for i as integer = 1 to passnum if points(i).y > points(i+1).y then exchange = 1 swap points(i), points(i+1) end if

' if the Y values are same, then sort based on x values... if points(i).y = points(i+1).y then if points(i).x > points(i+1).x then exchange = 1 swap points(i), points(i+1) end if end if next i passnum -= 1 wend

'' calc main left/right dividing slope...' dim as integer TLP, TRP dim as double MainSlope, CurSlope MainSlope = (points(1).x - points(NumOfPoints).x) / (points(1).y - points(NumOfPoints).y) '<--- this is the slope of the line from top to bottom points

'' compare the Main Slope to the slope to each of the other points to determine if each point is 'left' or 'right' for p as integer = 2 to NumOfPoints-1 CurSlope = (points(1).x - points(p).x) / (points(1).y - points(p).y) if CurSlope < MainSlope then points(p).side = -1 '<---left side else points(p).side = 1 '<---right side end if next p

TLP = 1 ' set top Left Point to the first point TRP = 1 ' set Top Right Point same as Top Left Point points(1).side = 0 ' set first point side to 0 (means is on BOTH sides)

' check for same y value of first two points if points(1).y = points(2).y then points(2).side = 1 ' set second point to RIGHT side only points(1).side = -1 ' set first point to LEFT side only, 0 means BOTH sides TRP = 2 ' set Top Right Point to the second point end if

' NOW, figure out the slopes of each point ot the next point on same side! ' This is where we figure out all the slopes, from one point to the next in line, for each side ' we will need these as we start filling the polygon and come to the next point/corner where we ' will change the slope value that we add to the left side X-value dim as integer curleftpoint = TLP, currightpoint = TRP, nextLeft, nextRight

' find all the left points, calc each slope do ' find next left point nextLeft = curleftpoint do nextLeft += 1 loop while points(nextLeft).side > 0

' got the next left, now calc slope to it from current left points(curleftpoint).Lslp = (points(curleftpoint).x - points(nextLeft).x) / (points(curleftpoint).y - points(nextLeft).y) ' save this next point points(curleftpoint).NLP = nextLeft curleftpoint = nextLeft loop while points(nextleft).side <> 0 'until at bottom point

' find all the right points, calc each slope do ' find next right point nextRight = currightpoint do nextRight += 1 loop while points(nextRight).side < 0

' got the next right, now calc slope to it from current right points(currightpoint).Rslp = (points(currightpoint).x - points(nextRight).x) / (points(currightpoint).y - points(nextRight).y) ' save this next point points(currightpoint).NRP = nextRight currightpoint = nextRight loop while points(nextRight).side <> 0 'until at bottom point

' ok, now we got a sorted array of points, each identified as to which 'side' they are on, with the slopes from one point to the next point on the same side stored' lets determine how many yvalues there will be in total... dim as integer NumOfYvalues = points(NumOfPoints).y - points(1).y + 1

' set the current point for each side dim as integer CLP = TLP, CRP = TRP

' this is where the magic happens.... ' Lx and Rx are the current x-values for each side ' points(CLP).Lslp and points(CRP).Rslp are the slopes (change in X) for the current point on each side (CLP=Current Left Point, CRP=Current Right Point) ' Lslp = Left Slope, Rslp = Right Slope... these are DOUBLES, not integers ' ' for direct screen access Dim As Integer w, h, bypp, pitch ScreenInfo w, h, , bypp, pitch Dim buffer As Any Ptr = ScreenPtr() Dim As Any Ptr row = buffer + (pitch * Cint(points(1).y)) Dim As UInteger Ptr pixel

dim as integer tester = 0 ' change to 0 for OldWay line draw, 1 = new way

for yvalue as integer = points(1).y + 1 to points(NumOfPoints).y 'iterate through all the yvalues ' calc the x-value for this y value for both Left and Right Lx += points(CLP).Lslp : Rx += points(CRP).Rslp select case tester case 0 ' OLD SLOW LINE DRAW METHOD ' draw the line between the to xvalues at this yvalue line (int(Lx), yvalue) - (int(Rx), yvalue), rgb(0,255,0) case 1 ' NEW WAY ' fast line draw! ' increment the row address (y-value) each time... row += pitch

' calc starting x-value address pixel = row + (Cint(Lx) shl 2)

for q as integer = int(Lx) to int(Rx)+1 ' length of row in pixels *pixel= RGB(0,0,255) pixel += 1 next q end select

' check to see if reached next left/right points... ' change current left point to the next left point! if yvalue >= points(points(CLP).NLP).y then CLP = points(CLP).NLP ' change current right point to the next right point! if yvalue >= points(points(CRP).NRP).y then CRP = points(CRP).NRP next yvalue screenunlock Sleep 1loop until MultiKey(1)

type vertice x as integer y as integer side as integer ' this value is either -1,0, or 1... -1 means left side, 0 means both sides, 1 means right side (both sides is a top or bottom point) NLP as integer ' the next left side point ...most points will only have a value in one of these, depending if it is a left or right point NRP as integer ' the next right side point Lslp as double ' this is the slope from this point towards the next point ON THE LEFT SIDE! ...most points will only have a value in one of these, depending if it is a left or right point Rslp as double ' this is the slope from this point towards the next point ON THE RIGHT SIDE!end type

NumOfPoints = Points(0).x''sort the array of points, from top to bottom, and left to right' dim as integer exchange = 1, passnum = NumOfPoints - 1 while passnum > 0 and exchange = 1 exchange = 0 for i as integer = 1 to passnum if points(i).y > points(i+1).y then exchange = 1 swap points(i), points(i+1) end if

' if the Y values are same, then sort based on x values... if points(i).y = points(i+1).y then if points(i).x > points(i+1).x then exchange = 1 swap points(i), points(i+1) end if end if next i passnum -= 1 wend

'' calc main left/right dividing slope...' dim as integer TLP, TRP dim as double MainSlope, CurSlope MainSlope = (points(1).x - points(NumOfPoints).x) / (points(1).y - points(NumOfPoints).y) '<--- this is the slope of the line from top to bottom points

'' compare the Main Slope to the slope to each of the other points to determine if each point is 'left' or 'right' for p as integer = 2 to NumOfPoints-1 CurSlope = (points(1).x - points(p).x) / (points(1).y - points(p).y) if CurSlope < MainSlope then points(p).side = -1 '<---left side else points(p).side = 1 '<---right side end if next p

TLP = 1 ' set top Left Point to the first point TRP = 1 ' set Top Right Point same as Top Left Point points(1).side = 0 ' set first point side to 0 (means is on BOTH sides)

' check for same y value of first two points if points(1).y = points(2).y then points(2).side = 1 ' set second point to RIGHT side only points(1).side = -1 ' set first point to LEFT side only, 0 means BOTH sides TRP = 2 ' set Top Right Point to the second point end if

' NOW, figure out the slopes of each point ot the next point on same side! ' This is where we figure out all the slopes, from one point to the next in line, for each side ' we will need these as we start filling the polygon and come to the next point/corner where we ' will change the slope value that we add to the left side X-value dim as integer curleftpoint = TLP, currightpoint = TRP, nextLeft, nextRight

' find all the left points, calc each slope do ' find next left point nextLeft = curleftpoint do nextLeft += 1 loop while points(nextLeft).side > 0

' got the next left, now calc slope to it from current left points(curleftpoint).Lslp = (points(curleftpoint).x - points(nextLeft).x) / (points(curleftpoint).y - points(nextLeft).y) ' save this next point points(curleftpoint).NLP = nextLeft curleftpoint = nextLeft loop while points(nextleft).side <> 0 'until at bottom point

' find all the right points, calc each slope do ' find next right point nextRight = currightpoint do nextRight += 1 loop while points(nextRight).side < 0

' got the next right, now calc slope to it from current right points(currightpoint).Rslp = (points(currightpoint).x - points(nextRight).x) / (points(currightpoint).y - points(nextRight).y) ' save this next point points(currightpoint).NRP = nextRight currightpoint = nextRight loop while points(nextRight).side <> 0 'until at bottom point

' ok, now we got a sorted array of points, each identified as to which 'side' they are on, with the slopes from one point to the next point on the same side stored' lets determine how many yvalues there will be in total... dim as integer NumOfYvalues = points(NumOfPoints).y - points(1).y + 1

' set the current point for each side dim as integer CLP = TLP, CRP = TRP

' this is where the magic happens.... ' Lx and Rx are the current x-values for each side ' points(CLP).Lslp and points(CRP).Rslp are the slopes (change in X) for the current point on each side (CLP=Current Left Point, CRP=Current Right Point) ' Lslp = Left Slope, Rslp = Right Slope... these are DOUBLES, not integers ' ' for direct screen access Dim As Integer w, h, bypp, pitch ScreenInfo w, h, , bypp, pitch Dim buffer As Any Ptr = ScreenPtr() Dim As Any Ptr row = buffer + (pitch * Cint(points(1).y)) Dim As UInteger Ptr pixel

dim as integer tester = 0 ' change to 0 for OldWay line draw, 1 = new way

for yvalue as integer = points(1).y + 1 to points(NumOfPoints).y 'iterate through all the yvalues ' calc the x-value for this y value for both Left and Right Lx += points(CLP).Lslp : Rx += points(CRP).Rslp select case tester case 0 ' OLD SLOW LINE DRAW METHOD ' draw the line between the to xvalues at this yvalue line (int(Lx), yvalue) - (int(Rx), yvalue), rgb(0,255,0) case 1 ' NEW WAY ' fast line draw! ' increment the row address (y-value) each time... row += pitch

' calc starting x-value address pixel = row + (Cint(Lx) shl 2)

for q as integer = int(Lx) to int(Rx)+1 ' length of row in pixels *pixel= RGB(0,0,255) pixel += 1 next q case 2 ' SUPER New Way with mem_clear method

end select

' check to see if reached next left/right points... ' change current left point to the next left point! if yvalue >= points(points(CLP).NLP).y then CLP = points(CLP).NLP ' change current right point to the next right point! if yvalue >= points(points(CRP).NRP).y then CRP = points(CRP).NRP next yvalue

I am getting around 500 fps with line and *pixel, but *pixel is a few fps faster.

Sometimes this box drops to 60 fps and stays there in graphics applications.I think it is OS stuff.Are you online during testing, sometimes java script in web pages in the background affects speed.You could trySetEnviron("fbgfx=GDI")at the top of the code.

type vertice x as integer y as integer side as integer ' this value is either -1,0, or 1... -1 means left side, 0 means both sides, 1 means right side (both sides is a top or bottom point) NLP as integer ' the next left side point ...most points will only have a value in one of these, depending if it is a left or right point NRP as integer ' the next right side point Lslp as double ' this is the slope from this point towards the next point ON THE LEFT SIDE! ...most points will only have a value in one of these, depending if it is a left or right point Rslp as double ' this is the slope from this point towards the next point ON THE RIGHT SIDE!end type

NumOfPoints = Points(0).x''sort the array of points, from top to bottom, and left to right' dim as integer exchange = 1, passnum = NumOfPoints - 1 while passnum > 0 and exchange = 1 exchange = 0 for i as integer = 1 to passnum if points(i).y > points(i+1).y then exchange = 1 swap points(i), points(i+1) end if

' if the Y values are same, then sort based on x values... if points(i).y = points(i+1).y then if points(i).x > points(i+1).x then exchange = 1 swap points(i), points(i+1) end if end if next i passnum -= 1 wend

'' calc main left/right dividing slope...' dim as integer TLP, TRP dim as double MainSlope, CurSlope MainSlope = (points(1).x - points(NumOfPoints).x) / (points(1).y - points(NumOfPoints).y) '<--- this is the slope of the line from top to bottom points

'' compare the Main Slope to the slope to each of the other points to determine if each point is 'left' or 'right' for p as integer = 2 to NumOfPoints-1 CurSlope = (points(1).x - points(p).x) / (points(1).y - points(p).y) if CurSlope < MainSlope then points(p).side = -1 '<---left side else points(p).side = 1 '<---right side end if next p

TLP = 1 ' set top Left Point to the first point TRP = 1 ' set Top Right Point same as Top Left Point points(1).side = 0 ' set first point side to 0 (means is on BOTH sides)

' check for same y value of first two points if points(1).y = points(2).y then points(2).side = 1 ' set second point to RIGHT side only points(1).side = -1 ' set first point to LEFT side only, 0 means BOTH sides TRP = 2 ' set Top Right Point to the second point end if

' NOW, figure out the slopes of each point ot the next point on same side! ' This is where we figure out all the slopes, from one point to the next in line, for each side ' we will need these as we start filling the polygon and come to the next point/corner where we ' will change the slope value that we add to the left side X-value dim as integer curleftpoint = TLP, currightpoint = TRP, nextLeft, nextRight

' find all the left points, calc each slope do ' find next left point nextLeft = curleftpoint do nextLeft += 1 loop while points(nextLeft).side > 0

' got the next left, now calc slope to it from current left points(curleftpoint).Lslp = (points(curleftpoint).x - points(nextLeft).x) / (points(curleftpoint).y - points(nextLeft).y) ' save this next point points(curleftpoint).NLP = nextLeft curleftpoint = nextLeft loop while points(nextleft).side <> 0 'until at bottom point

' find all the right points, calc each slope do ' find next right point nextRight = currightpoint do nextRight += 1 loop while points(nextRight).side < 0

' got the next right, now calc slope to it from current right points(currightpoint).Rslp = (points(currightpoint).x - points(nextRight).x) / (points(currightpoint).y - points(nextRight).y) ' save this next point points(currightpoint).NRP = nextRight currightpoint = nextRight loop while points(nextRight).side <> 0 'until at bottom point

' ok, now we got a sorted array of points, each identified as to which 'side' they are on, with the slopes from one point to the next point on the same side stored' lets determine how many yvalues there will be in total... dim as integer NumOfYvalues = points(NumOfPoints).y - points(1).y + 1

' set the current point for each side dim as integer CLP = TLP, CRP = TRP

' this is where the magic happens.... ' Lx and Rx are the current x-values for each side ' points(CLP).Lslp and points(CRP).Rslp are the slopes (change in X) for the current point on each side (CLP=Current Left Point, CRP=Current Right Point) ' Lslp = Left Slope, Rslp = Right Slope... these are DOUBLES, not integers ' ' for direct screen access Dim As Integer w, h, bypp, pitch ScreenInfo w, h, , bypp, pitch Dim buffer As Any Ptr = ScreenPtr() Dim As Any Ptr row = buffer + (pitch * Cint(points(1).y)) Dim As UInteger Ptr pixel

dim as integer tester = 0 ' change to 0 for OldWay line draw, 1 = new way

for yvalue as integer = points(1).y + 1 to points(NumOfPoints).y 'iterate through all the yvalues ' calc the x-value for this y value for both Left and Right Lx += points(CLP).Lslp : Rx += points(CRP).Rslp dim as uinteger NumOfBytes = (int(Rx)-int(Lx)+1) shl 2 select case tester case 0 ' OLD SLOW LINE DRAW METHOD ' draw the line between the to xvalues at this yvalue line (int(Lx), yvalue) - (int(Rx), yvalue), rgb(0,255,0) case 1 ' NEW WAY ' fast line draw! ' increment the row address (y-value) each time... row += pitch

' check to see if reached next left/right points... ' change current left point to the next left point! if yvalue >= points(points(CLP).NLP).y then CLP = points(CLP).NLP ' change current right point to the next right point! if yvalue >= points(points(CRP).NRP).y then CRP = points(CRP).NRP next yvalue

dodicat wrote:I am getting around 500 fps with line and *pixel, but *pixel is a few fps faster.

Sometimes this box drops to 60 fps and stays there in graphics applications.I think it is OS stuff.Are you online during testing, sometimes java script in web pages in the background affects speed.You could trySetEnviron("fbgfx=GDI")at the top of the code.

"SetEnviron("fbgfx=GDI")" didn't have effect... its really strange. Since I did tests with various SLEEP values (1 thru 11 all resulted in same FPS), that tells me that it might be video related? I don't know.... I would gues the program is running fast, but (maybe in conjunction with either screenlock/unlock and/or sleep, something caps the video speed.... no, that doesn't make sense unless somehow the program was 'waiting' for something during that time, like a vsync (which would explain the 60 fps limit, right?)

what Π$/- me off is that 'sometimes' I get to see the real speed... I ran that test program and was getting 300fps, then it dropped down to 65.... cant get it to over 65 now though...

I did test running code with no other programs running (not online or anything), from a fresh restart of computer...

another strange thing... when I run the speed test which just shows how much time the routine takes, I get around .0019 or .0018... but those translate to 1/.0018 = 555fps! so it is speeding through them, repeatedly, because the times are averaged over 30 loops... its like the fps counter is off somehow?! lol

type vertice x as integer y as integer side as integer ' this value is either -1,0, or 1... -1 means left side, 0 means both sides, 1 means right side (both sides is a top or bottom point) NLP as integer ' the next left side point ...most points will only have a value in one of these, depending if it is a left or right point NRP as integer ' the next right side point Lslp as double ' this is the slope from this point towards the next point ON THE LEFT SIDE! ...most points will only have a value in one of these, depending if it is a left or right point Rslp as double ' this is the slope from this point towards the next point ON THE RIGHT SIDE!end type

NumOfPoints = Points(0).x''sort the array of points, from top to bottom, and left to right' dim as integer exchange = 1, passnum = NumOfPoints - 1 while passnum > 0 and exchange = 1 exchange = 0 for i as integer = 1 to passnum if points(i).y > points(i+1).y then exchange = 1 swap points(i), points(i+1) end if

' if the Y values are same, then sort based on x values... if points(i).y = points(i+1).y then if points(i).x > points(i+1).x then exchange = 1 swap points(i), points(i+1) end if end if next i passnum -= 1 wend

'' calc main left/right dividing slope...' dim as integer TLP, TRP dim as double MainSlope, CurSlope MainSlope = (points(1).x - points(NumOfPoints).x) / (points(1).y - points(NumOfPoints).y) '<--- this is the slope of the line from top to bottom points

'' compare the Main Slope to the slope to each of the other points to determine if each point is 'left' or 'right' for p as integer = 2 to NumOfPoints-1 CurSlope = (points(1).x - points(p).x) / (points(1).y - points(p).y) if CurSlope < MainSlope then points(p).side = -1 '<---left side else points(p).side = 1 '<---right side end if next p

TLP = 1 ' set top Left Point to the first point TRP = 1 ' set Top Right Point same as Top Left Point points(1).side = 0 ' set first point side to 0 (means is on BOTH sides)

' check for same y value of first two points if points(1).y = points(2).y then points(2).side = 1 ' set second point to RIGHT side only points(1).side = -1 ' set first point to LEFT side only, 0 means BOTH sides TRP = 2 ' set Top Right Point to the second point end if

' NOW, figure out the slopes of each point ot the next point on same side! ' This is where we figure out all the slopes, from one point to the next in line, for each side ' we will need these as we start filling the polygon and come to the next point/corner where we ' will change the slope value that we add to the left side X-value dim as integer curleftpoint = TLP, currightpoint = TRP, nextLeft, nextRight

' find all the left points, calc each slope do ' find next left point nextLeft = curleftpoint do nextLeft += 1 loop while points(nextLeft).side > 0

' got the next left, now calc slope to it from current left points(curleftpoint).Lslp = (points(curleftpoint).x - points(nextLeft).x) / (points(curleftpoint).y - points(nextLeft).y) ' save this next point points(curleftpoint).NLP = nextLeft curleftpoint = nextLeft loop while points(nextleft).side <> 0 'until at bottom point

' find all the right points, calc each slope do ' find next right point nextRight = currightpoint do nextRight += 1 loop while points(nextRight).side < 0

' got the next right, now calc slope to it from current right points(currightpoint).Rslp = (points(currightpoint).x - points(nextRight).x) / (points(currightpoint).y - points(nextRight).y) ' save this next point points(currightpoint).NRP = nextRight currightpoint = nextRight loop while points(nextRight).side <> 0 'until at bottom point

' ok, now we got a sorted array of points, each identified as to which 'side' they are on, with the slopes from one point to the next point on the same side stored' lets determine how many yvalues there will be in total... dim as integer NumOfYvalues = points(NumOfPoints).y - points(1).y + 1

' set the current point for each side dim as integer CLP = TLP, CRP = TRP

' this is where the magic happens.... ' Lx and Rx are the current x-values for each side ' points(CLP).Lslp and points(CRP).Rslp are the slopes (change in X) for the current point on each side (CLP=Current Left Point, CRP=Current Right Point) ' Lslp = Left Slope, Rslp = Right Slope... these are DOUBLES, not integers ' ' for direct screen access Dim As Integer w, h, bypp, pitch ScreenInfo w, h, , bypp, pitch Dim buffer As Any Ptr = ScreenPtr() Dim As Any Ptr row = buffer + (pitch * Cint(points(1).y)) Dim As UInteger Ptr pixel

dim as integer tester = 0 ' change to 0 for OldWay line draw, 1 = new way

tf = Timer

for yvalue as integer = points(1).y + 1 to points(NumOfPoints).y 'iterate through all the yvalues ' calc the x-value for this y value for both Left and Right Lx += points(CLP).Lslp : Rx += points(CRP).Rslp dim as uinteger NumOfBytes = (int(Rx)-int(Lx)+1) shl 2 select case tester case 0 ' OLD SLOW LINE DRAW METHOD ' draw the line between the to xvalues at this yvalue line (int(Lx), yvalue) - (int(Rx), yvalue), rgb(0,255,0) case 1 ' NEW WAY ' fast line draw! ' increment the row address (y-value) each time... row += pitch

' check to see if reached next left/right points... ' change current left point to the next left point! if yvalue >= points(points(CLP).NLP).y then CLP = points(CLP).NLP ' change current right point to the next right point! if yvalue >= points(points(CRP).NRP).y then CRP = points(CRP).NRP next yvalue totalTimeFILL += (Timer-tf) totalTime += (Timer-t) screenunlock Sleep 1next looper Locate 5,3 averTime = totalTime / 300 Print "Average Time taken for 300 loops ";averTime Locate 7,3 fps = 1/averTime Print "Which translates into ";fps;" FPS"