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.

The 20 Line Challenge / Fast filled circles (DBP command replacement)

Author
Message
David T
Retired Moderator
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 19th Mar 2003 22:12
I've remade the circle command complete with shading too. It's around 500 fps on my beast of a machine, shouldn't be too slow

You are the http://s15.sitemeter.com/meter.asp?site=s15dtsig[/img]th person to view this signature.
Programmers don't die, they just Gosub without return....
Easily Confused
21
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 20th Mar 2003 01:25 Edited at: 20th Mar 2003 01:46
Out of curiosity, how fast are these versions?



...and



Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
David T
Retired Moderator
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 20th Mar 2003 21:21
First snippet: ~219
Second: ~256 when drawing (600 when not but that doesn't count)

You are the th person to view this signature.
Programmers don't die, they just Gosub without return....
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 20th Mar 2003 21:56
You have far too much overdraw (writing the same pixels again and again) and your calculations are too intensive.

Here's a replacement with no overdraw and less intensive calculations (uses pythagoras instead of sin/cos) - it was as fast as I could make it - this was version 5 or 6 (OK, I was bored!).



These are the fps I get with each one.
David89: 233
EC/1: 415
EC/2: 310
Mine: 445

Not drawing anything in the loop gets me 495 fps. It's not a super machine either - 850Mhz PIII laptop with an ATI M4 Mobility.
David T
Retired Moderator
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 20th Mar 2003 22:09
I was wondering - what ovewrdraw?

My function draws horizontal lines across the screen from one side of the circle to the other. Since the lines are not horizontal, that cannot be diagonal, and when that happens you get overdraw.

.........
.....=====......
.================.
.================.
.================.
.================.
.....=====......
.........

How's overdraw possible? (within one use of the function)

You are the th person to view this signature.
Programmers don't die, they just Gosub without return....
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 20th Mar 2003 22:38 Edited at: 20th Mar 2003 22:41
Because you are using angles you are drawing some of the horizontal lines over previously drawn lines.

For example, using a cirle with a radius of 50, when you work out the x coord for angles 88 and 89 degrees you will see that they both come out as 49 point something. When you draw you drop the fractions they will overlap.

Here's a piece of code that counts the number of overdrawn lines:


EC's code had much more overdraw but it was hardware accelerated.
Easily Confused
21
Years of Service
User Offline
Joined: 22nd Oct 2002
Location: U.K. Earth. (turn right at Venus)
Posted: 20th Mar 2003 22:51
Very true, especialy when drawing smaller circles.

Programming anything is an art, and you can't rush art.
Unless your name is Bob Ross, then you can do it in thirty minutes.
David T
Retired Moderator
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: England
Posted: 21st Mar 2003 21:30
Ah, I see. Looks like my diagram didn't turn out too well

I'm not a maths expert, just had an idea

You are the th person to view this signature.
Programmers don't die, they just Gosub without return....
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 22nd Mar 2003 15:43
Here's another even faster version I think I'll stop with this one now!



This one draws a central box, and then fills out the top/bottom/sides.

Instead of timing using fps, I've switched to timing how long it takes to draw 10000 circles.
This code reduced the time from 2.725 seconds to 1.984 seconds on my pc - a drop of about 28%.

Login to post a reply

Server time is: 2024-04-26 22:28:53
Your offset time is: 2024-04-26 22:28:53