drawing a line old school (IE: doing it by hand)
cbxA word of caution ... I can't even under stand some of the stuff I am trying to say in this post, I've written too much to just delete it all and start from scratch, so you will have to muddle thru it just as I did ... As per my prev posting [url]http://www.vbgamer.com/msgboard/topic.asp?TOPIC_ID=56[/url] the reason I was creating the ray rect function was this. I am thinking about trying to make a doom clone for vb.net using directx9 and using quad BSP trees for the map etc. I thought doing if I took the line and broke it down into blocks the size of a pixel, that It would be faster then calculating the path of a line. Here's what I mean ... (a basic premis for drawing the pixels that make up a line) [code] DeltaX = point2.X - point1.X DeltaY = point2.Y - point1.Y Slope = DeltaY / DeltaX YPos = point1.Y For idx = point1.X To point2.X ' draw pixel at idx, YPos YPos += Slope Next [/code] ... I realize that the code above is flawd but the basic math is there. Now from the code above, I had it in my head that doing it that way would be slower then calculating the hit boxes of a line etc. My reasoning was that you could be transversing a line that is over 1000+ in length. ... heres my problem. I just wrote a sample app that draws a line manually using vb.net (Not asm not inline asm but slower than native VB.NET managed code!) and as it turns out drawing the line by hand in vb.net is instantaneous. I am running on a duel monitor rig and stretch the window to the max across both screens and draw a line as long as I could and still my timming code is saying that it's drawing it instantly with no delay. Let me re-iterate a line over 2500 in length does not in cure a speed penalty. That means that my managed code while still a debug build can execute a loop over 2500 times and not even flinch? Mabe It's just because for most of my .. tech life ... I have been using a 486 and I am hoplessly brain drained to think that my athlon xp 1600 can't process a 2500+ loop without taking 5 seconds to do so... I guess the whole point of this post was to vent my astonisment that my mid level system could handle 2500+ loop (plus code) and not even hickup .... Of course this means I have been wasting my time focusing on how to parse a line when I knew all along what the fasted way to do it was ... DOH! (In my best homer simpson impression)
Eric ColemanIf you're only timing the draing of 1 line, then the resolutions of your timing code may be too small. Instead of drawing a line that you create with the mouse, hard code the start and end points of the line in your program, say (1,1), (1000,1000), then have another loop around the drawing code so that you can draw the line multiple times. Something like For intCounter = 1 to 10000 [...] Next. This should increase the drawing time for you, if not, then just increase the counter number and draw the line more.