Draw performance
[1/9] from: davidegessi::tin::it at: 21-Jan-2003 19:16
Hi all,
I've read the new draw documentation in the rebol website and make some
exercises, one of them is Bubbles (inspired by a BeOS screensaver).
I have a P3 733, WinXP and the max number of bubbles that i can run is about
100, greater values produces flickering.
How, in this examples, can I improve the frame/rate ?
[Strange, but seems that fill circles or empty ones produces the same
performances.]
Ciao
Davide
8<----------
REBOL [
Title: "Bubbles"
File: %bubbles.r
Date: 21-Jan-2003
Version: 0.0.1
Author: "Davide Gessi"
Email: [davidegessi--tin--it]
History: {
v0.0.1
- Prima release.
}
]
pick-velocity: func [
"pick a random non-zero velocity for a bubble"
][
v: 0x0
while [equal? v 0x0] [
v: subtract random 20x20 10x10
]
return v
]
create-bubbles: func [
"Creates a block containing bubbles information"
N [integer!] "how many bubble ?"
][
ret: make block! N
loop N [
append/only ret reduce [
to-pair reduce [bbwidth / 2 bbheight / 2] ;position
pick-velocity ;velocity
random 255.255.255 ;color
random 30 ;radius
]
]
return ret
]
step-bubbles: func [
"Makes bubbles do a step and return a draw sequence"
bubbles [block!] "the bubbles"
][
ret: copy []
bubbles: head bubbles
forall bubbles [
b: first bubbles
b/1: b/1 + b/2
if any [b/1/1 < 0 b/1/1 > bbwidth b/1/2 < 0 b/1/2 > bbheight] [
;New bubble
b/1: to-pair reduce [bbwidth / 2 bbheight / 2] ;position
pick-velocity ;velocity
b/3: random 255.255.255 ;color
b/4: random 30 ;radius
]
;append ret reduce ['pen b/3 'fill-pen b/3 'circle b/1 b/4]
append ret reduce ['pen b/3 'circle b/1 b/4]
]
return ret
]
bbwidth: 800
bbheight: 600
bb: create-bubbles 100
view layout compose [
blackboard: box (to-pair reduce [bbwidth bbheight]) black effect [
draw [
pen red
fill-pen gray
circle 50x50 10
]
]
rate 20 feel [
engage: func [f a e] [
if equal? a 'time [
blackboard/effect: reduce ['draw step-bubbles bb]
show blackboard
]
]
]
]
8<----------
--
Windows XP is a 32-bit shell for a 16-bit extension to an 8-bit operating
system designed for a 4-bit microprocessor by a 2-bit company that can't
stand one bit of competition.
[2/9] from: giuseppe:chillemi:omniaw:it at: 21-Jan-2003 20:08
Davide,
circle filling is performed by graphic hardware. The circle perimeter is calculated by
the CPU.
Giuseppe
-----Messaggio originale-----
Da: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]Per conto di
Davide Gessi
Inviato: marted=EC 21 gennaio 2003 19.16
A: Rebol-List
Oggetto: [REBOL] Draw performance
....
[Strange, but seems that fill circles or empty ones produces the same
performances.]
....
[3/9] from: anton:lexicon at: 22-Jan-2003 17:53
Look to the bottom.
Try changing rate 20 to rate 48
That changes the rate at which the box
receives events of type 'time.
Anton.
[4/9] from: rebol:optushome:au at: 22-Jan-2003 17:06
Hi Davide,
Nice.
The number isn't as much of a problem as the window size, large faces give
View a hard time to keep refreshing.
One trick which works with some draw operations is to make sure the offset
of the main drawing area is at 0x0 or Origin 0x0, I have scripts here which
made the speed increase by doing this.
I took a different approach when I wrote my ballz.r script doing it with
multiple faces instead of using draw. It would be interesting to re-write
using draw, but I think draw would be slower because it would need to
interpret the block each time.
If you want to grab ballz.r it is at
http://www.rebolforces.com/demos/ballz/
You will need to download the subdirectory with gfx too. Apologies that they
is no autodownload for this, but I wrote the script for IOS where that
wasn't needed. When you run it hit the "+" a few times to see how fast it
can get.
Cheers,
Allen K
[5/9] from: davidegessi:tin:it at: 22-Jan-2003 16:34
> Hi Davide,
> ......
> I took a different approach when I wrote my ballz.r script doing it with
> multiple faces instead of using draw. It would be interesting to re-write
> using draw, but I think draw would be slower because it would need to
> interpret the block each time.
wow ... ballz seems a demo wrote in C !
Thanks, I'll study your source (seems very advanced to me) :)
So, the problem in long draw bloks is the parsing phase ?
Davide
[6/9] from: davidegessi:tin:it at: 22-Jan-2003 16:31
> -----Original Message-----
> From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]On Behalf Of
<<quoted lines omitted: 7>>
> receives events of type 'time.
> Anton.
Yes, I've tried several rates but seems that the phase step+draw take about
1/20 sec on my pc, so if I increase the rate nothing happens.
Davide
[7/9] from: davidegessi:tin:it at: 22-Jan-2003 16:31
> -----Original Message-----
> From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]On Behalf Of
<<quoted lines omitted: 6>>
> The circle perimeter is calculated by the CPU.
> Giuseppe
Oh yes, not so strange at least ... :)
Davide
[8/9] from: rebol:optushome:au at: 23-Jan-2003 6:29
Hi Davide,
A little trick to make it seem faster is to increase the stepping per timer
event.
For example replace your engage func with below.
engage: func [f a e /local bubs] [
if equal? a 'time [
; Any faster if the stepping is done 10 times per tick?
bubs: loop 10 [step-bubbles bb]
blackboard/effect: reduce ['draw bubs]
show blackboard
]
]
Simply adjust the number in the loop to get a required speed
Cheers,
Allen
[9/9] from: rotenca:telvia:it at: 23-Jan-2003 18:19
Hi,
on my system w98 celeron 333, a window 800x600 with a box 800x600 with effect:
none and a show box at every time event reaches 15/16 fps max.
If I add a void draw to the box:
effect: [draw []]
max fps goes down to
9/10.
It is slow the Rebol View/draw/show system for itself.
If i'm not wrong, the max rate is limited under windows also with smaller
window.
On my system it seems 17/18.
Max rate should be activated with:
layout [box rate 0]
---
Ciao
Romano
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted