Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
standard GfxLib speed
#1
I wanted to make a mouse cursor. But the screencopy is sooooo slow. WHY? In 640x480x24 mode on my P500MHz the cursor jumps and it looks like it's about 10-15 FPS.

Here is the sample code. Any ideas gow to make it faster/more efficient?


Code:
screen 18, 24, 2, 1
screenset 1,0

line (0,0)-(27,27), rgb(255,0,255), BF
line (0,0)-(27,27), rgb(255,255,255)
dim cursor((28 * 28 * 4) + 4)
get (0,0)-(27,27), cursor

do
   if MULTIKEY(&h01) then end
   getmouse mx,my
   cls
   circle (320, 240), 200, rgb(255,0,0)
   put (mx, my), cursor, TRANS
   screencopy 1,0
loop
img]http://img59.exs.cx/img59/7237/aqsig2el.png[/img]
Reply
#2
The code seems to run just fine on my PC (P4 1.7Ghz). If I turn off the CLS, I can see that the "mouse graphic" stutters across the screen, but if you really pay attention to the windows mouse cursor it also has a slightly jerky movement.
ature has its way of warning a person away from danger: The distinct black and white coloration on a skunk, the chilling buzz of a rattlesanke, a redneck handing you his beer and saying "Watch this!"
Reply
#3
You only draw on every second page, or so it seems.

Don't you have to set the working page?
Reply
#4
1.- Do page flipping instead of double buffering.
2.- Remove that CLS! NOW!! Big Grin
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#5
Remember gfxlib is a software renderer. As such, when you do big memory copies, the speed decreases a lot... gfxlib uses MMX, but copying a whole 640x480x24 screen buffer on a P500 will surely degrade performance. This happens with gfxlib, but also with other software based libs like TinyPTC, Allegro and SDL (these last two of course when you use software surfaces).
Doing double buffering in hires modes is widely known to be slow for this reason. Better use page flipping as na_th_an suggested :wink:
ngelo Mottola - EC++
Reply
#6
Also, do to the layout of the memory in a 24-bit mode, it will be slow. Better to go with 32-bit which can be accelerated (even though it's not with gfxlib) or 16-bit which can alos be accelerated but is only half the memory.
Life is like a box of chocolates', hrm, WTF, no it isn't, more like, 'life is like a steaming pile of horse crap.'
Reply
#7
Thanks for all the replies, this is really helpful.
One more question: How to do the "page flipping"? The FLIP function is just an alias of SCREENCOPY...

Is it something like this?:


Code:
do
   screenset 1,0
   ' drawing routines here
   screenset 0,1
loop
img]http://img59.exs.cx/img59/7237/aqsig2el.png[/img]
Reply
#8
Exactly. Look at the gfxlib.txt documentation, MULTIKEY example; it uses page flipping. Let me know how well it performs!
ngelo Mottola - EC++
Reply
#9
Oh yeah, never use 24-bit modes, they are 3 to 5 times slower than 16-bit or even 32-bit, due the way pixels are stored.
Reply
#10
On my comp, 32bit is way faster than 16bit, not to mention how SLOW! 8bit is... but it's prolly because of my drawing routines Tongue
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)