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.
yes, it's need calculate alpha tables.
Is it unavoidable? May be it would be better to calculate these tables on set_mode or module import?
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.
edit
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).
alpha tables consume lot of memory, and you not all games need it...
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 ;)
yes, you can do un alpha_draw when you start the game...