Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Why is my line draw so slow?

Author
Message
Anagon
23
Years of Service
User Offline
Joined: 6th Apr 2003
Location:
Posted: 6th Apr 2003 22:17
Hey all,

My kid just bought DB and I decided to toy with it a bit. Dregged up an algorithm I originally wrote on Apple ][ and VIC-20, just to start putting the language through its paces.

Anyway, I'm rather surprised at just how slow the following line drawing code is (about 12 seconds). Am I not setting something correctly to let it fly at full speed?

Or, does the DB team need to go reread Foley, van Dam, Feiner, and Huges pp. 74, "Midpoint Line Algorithm" so they can implement a Bresenham incremental line scan-conversion because DB is drawing its own lines instead of using Windows GDI calls?



Anagon

P.S. Not that this is a big deal - looks like the core language is pretty snappy - a normal FOR loop flys through 1000000 iterations. The following happens in about 1 second.

Hamish McHaggis
23
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 6th Apr 2003 23:28
The line command is incredibly slow, as with all the 2D commands in DB. DBPro fixes that problem I think, but I'd just stick with DB if you've already bought it, its not the end of the world (I have DB not DBPro).

Why the hell'd you ask me for crying out loud!?!
John H
Retired Moderator
23
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 7th Apr 2003 01:51
A way around this would be to use the BOX command and just make it smaller If you need it to get bigger or something you could GET IMAGE and make it a sprite and stretch it

Cheers!

RPGamer

PS If he needs any help, I can be contacted on most the instant messengers. They are as follows...

AIM: Johnrocs
MSN: [email protected]
yahoo!: rpggamer8

I already help a lot of people online, so its no biggy

Current Project: Eternal Destiny
Tech Demo - Colan Island: Currently 716 Lines
Anagon
23
Years of Service
User Offline
Joined: 6th Apr 2003
Location:
Posted: 7th Apr 2003 02:22
Found it!

The DB default is to automatically sync frames - this delays drawing each line until a frame refresh occurs (until the electron beam is off the screen and has not started drawing the next frame).

If I add "sync on" to the beginning of my program, it screams (instantly draws the final image; individual draws can no longer be seen). "sync on" means turn on MANUAL sync (I thought it was turning on autosync, so didn't even mention that using "sync off" made no difference).

If you don't feel like watching text or lines draw, then add "sync on" to the top of your program.

Cheers!

Anagon

xmen
23
Years of Service
User Offline
Joined: 27th Jan 2003
Location:
Posted: 7th Apr 2003 03:04
`try this

sync on
r = screen width()-1
b = screen height()-1
r2 = r/2
b2 = b/2

ytox# = (1.0*r)/b
xtoy# = (1.0*b)/r

for x=0 to r2 step 4
y=x*xtoy#
line x,0,0,b2-y
line x+r2,0,r,y
line r,b2+y,r-x,b
line r2-x,b,0,b-y
sync

next x

suspend for key

end
John H
Retired Moderator
23
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 7th Apr 2003 05:26
Yes syncing is always a good idea I looked over that it wasnt there, silly me

Glad its working

RPGamer

Current Project: Eternal Destiny
Tech Demo - Colan Island: Currently 716 Lines
Hamish McHaggis
23
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 7th Apr 2003 19:05
I just made that comment off of the top of my head, as the code made my computer crash twice.

Why the hell'd you ask me for crying out loud!?!

Login to post a reply

Server time is: 2026-06-11 15:09:30
Your offset time is: 2026-06-11 15:09:30