Bennu Game Development

English Forums => Helpdesk => Topic started by: EugeneP on November 12, 2010, 05:44:44 PM

Title: [bug?] drawing_alpha() takes more than 2 seconds
Post by: EugeneP on November 12, 2010, 05:44:44 PM
I suddenly found why my program freezes for second randomly.
First call of drawing_alpha() takes few seconds:
[code language="bennu"]import "mod_video"
import "mod_draw"
import "mod_say"
import "mod_time"

process main()
local
  int t1,t2;
end
begin
  set_mode( 320, 240, 16 );
  say("Start");
 
  t1 = get_timer();
  drawing_alpha( 127 );
  t2 = get_timer();
  say("dT = "+(t2-t1));
 
  t1 = get_timer();
  drawing_alpha( 255 );
  t2 = get_timer();
  say("dT = "+(t2-t1));
 
  say("End");
end;[/code]

Output ( OS Linux, r181 )
Start
dT = 2280
dT = 0
End


On Wiz, Bennu r165, results are similar.

Only the first call of drawing_alpha takes unreasonably much time. Next calls executed fast.
Title: Re: [bug?] drawing_alpha() takes more than 2 seconds
Post by: SplinterGU on November 12, 2010, 07:43:24 PM
yes, it's need calculate alpha tables.
Title: Re: [bug?] drawing_alpha() takes more than 2 seconds
Post by: EugeneP on November 12, 2010, 08:33:07 PM
Is it unavoidable? May be it would be better to calculate these tables on set_mode or module import?
Title: Re: [bug?] drawing_alpha() takes more than 2 seconds
Post by: SplinterGU on November 12, 2010, 08:38:25 PM
nop, because depend of the alpha value that you want...

yes, this can be calculate on set_mode.

and this need a better implement, because the tables are calculate once.
Title: Re: [bug?] drawing_alpha() takes more than 2 seconds
Post by: SplinterGU on November 12, 2010, 08:47:49 PM
edit
Title: Re: [bug?] drawing_alpha() takes more than 2 seconds
Post by: handsource-dyko on November 13, 2010, 01:00:33 PM
Isn't it easier to use a lookup table loaded from a dat file?
Or to calculate this at the start of bgdi's execution?

This sort of methode was common practice in the dos days, according to
the maker of the dukenumen 3d's build engine this was the fastest way.

(Oke, computer back then sucked at floating point math).
Title: Re: [bug?] drawing_alpha() takes more than 2 seconds
Post by: SplinterGU on November 13, 2010, 03:06:00 PM
alpha tables consume lot of memory, and you not all games need it...
Title: Re: [bug?] drawing_alpha() takes more than 2 seconds
Post by: Drumpi on November 13, 2010, 04:48:22 PM
You also can do a "drawing_alpha" call at start of your program or in resources loading, so it takes 2 seconds more when loading FPGs, etc, and not when playing your game ;)
Title: Re: [bug?] drawing_alpha() takes more than 2 seconds
Post by: SplinterGU on November 13, 2010, 09:47:39 PM
yes, you can do un alpha_draw when you start the game...