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.

Newcomers DBPro Corner / Slow 2D commands

Author
Message
Mumboz
21
Years of Service
User Offline
Joined: 3rd Aug 2003
Location: Denmark
Posted: 4th Aug 2003 02:05
Hi

I've just been playing around with a demo of Dark Basic, but there is one thing im quite curious about. When im running the following code, it runs very slow:

for x = 0 to 639
for y = 0 to 479
dot x,y
next y
next x

All it does is filling the screen pixel by pixel - nothing serious, but i've noticed it also happens when using the POINT() command. Adding a "Sync rate 0" makes it run a bit faster, but still.

A similar program in QBasic fills the entire screen in the time it takes the program in Dark basic to fill one row.

Is there any way to speed up the "DOT", "POINT()", and similar commands or is it just my computer there is something wrong with?


- Mumboz
spooky
22
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 4th Aug 2003 02:19
LOCK PIXELS before you start and UNLOCK PIXELS when you finish. It will fill whole screen almost instantly

The programmer formerly known as sonic
Mumboz
21
Years of Service
User Offline
Joined: 3rd Aug 2003
Location: Denmark
Posted: 4th Aug 2003 02:56
Thank for a fast answer, but i can't get it to work. It doesn't seem like the command "LOCK PIXELS" exists (im only using Dark Basic non-pro). I found a command called "LOCK BACKBUFFER" but it didn't seem to work either.


- Mumboz

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 4th Aug 2003 03:23 Edited at: 4th Aug 2003 03:28
Try this:



Though you would never do that anyway, you would use:

CLS RGB(255,255,255)

to do the same thing anyway.

TDK
CloseToPerfect
21
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 4th Aug 2003 03:26

109 ms on my 1 gig machine not to shabby for for more then 300,000 dot commands.
CTP
CloseToPerfect
21
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 4th Aug 2003 03:28
scratch my code, It's for DBP, I didn't see you was using DBC, sorry.
CTP
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 4th Aug 2003 03:29
CloseToPerfect:

Quote: "
Thank for a fast answer, but i can't get it to work. It doesn't seem like the command "LOCK PIXELS" exists (im only using Dark Basic non-pro).
"




TDK
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 4th Aug 2003 03:30
Oops - you noticed while I was posting!

TDK
Mumboz
21
Years of Service
User Offline
Joined: 3rd Aug 2003
Location: Denmark
Posted: 4th Aug 2003 13:03
Thanks for the replies.

TDK: Never thought of using sync that way - it definatly works faster now

Exactly what would the LOCK BACKBUFFER command do? Is it similar to LOCK PIXELS?

Attreid
21
Years of Service
User Offline
Joined: 27th Nov 2002
Location:
Posted: 4th Aug 2003 14:06
you should read the help about those commands

I tried to fill the screen pixel after pixel with your snippet, with DBP and DBC :
2418 milli-seconds
3466 milli-seconds

but there's a way a bit faster to fill your screen :
Sync On: Sync Rate 0
st = timer()
Ink RGB(255,255,255),0
box 0,0,640,480
Sync
et = timer()
write to clipboard str$(et-st)


with DBP : 0 milli-seconds
with DBC : 10 milli-seconds

"He will come...the voice from the outer world,
bringing the holy war, the Jihad, which will cleanse the Universe and bring us out of darkness."
Mumboz
21
Years of Service
User Offline
Joined: 3rd Aug 2003
Location: Denmark
Posted: 4th Aug 2003 20:12
Attreid: I was more wondering if LOCK BACKBUFFER and LOCK PIXELS are the same? I don't have access to Dark Basic Pro, so i can't really tell myself

Concerning my example - the goal was not to fill the entire screen as fast as possible, but just to test the speed of the DOT command.

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 4th Aug 2003 23:48
LOCK BACKBUFFER locks the screen surface
LOCK PIXELS locks the current bitmap surface (which may be the screen)
Mumboz
21
Years of Service
User Offline
Joined: 3rd Aug 2003
Location: Denmark
Posted: 5th Aug 2003 01:40
IanM: Meaning those two commands can do the same thing (sorry if im asking dumb questions)?

Anyway, i've found out that the above mentioned method with adding a SYNC ON etc... speeds the program up when using DOT, but when using POINT() it only runs 2x as fast when using SYNC. I've included a small example. My "score" is 3625 when sync is off and 1432 when sync is on - however, i still think this i rather slow....is there any way to speed this further up?

To compare POINT() with DOT replace "temp = point(x,y)" with "dot x,y" - using dot and sync=on it takes 10 ms run.

Any feedback appreciated

- Mumboz

Login to post a reply

Server time is: 2024-11-25 02:01:24
Your offset time is: 2024-11-25 02:01:24