Browsing this Thread:
1 Anonymous Users
|
Re: Slow start program with text size calculation (only first time!)
|
||||
|---|---|---|---|---|
|
Just can't stay away
![]() |
OK,
Function y=f(x) lettersize=f(gamenamesize) is not linear so calculation will be hard and different for different fonts. I decide use precalculated table with best fontsize for every 100 px screen from 200 to 2000 width. it will be not scalable as I wish but gamename should be visible (readable) at any window size.
Posted on: 2011/4/18 17:41
|
|||
|
||||
|
Re: Slow start program with text size calculation (only first time!)
|
||||
|---|---|---|---|---|
|
Home away from home
![]()
|
@mrdarek
At a guess, OS4 is having to generate a HUGE number of (differently sized) fonts for your program, and this takes some time. But after the first run they are cached, and so your program runs fast. So you need to fix your algorithm to try (a lot!) fewer font sizes. The simplest (and least effective) solution would be to make z3 increase in a larger (but still fixed) jump than +1. A better solution would make a crude estimate of how large z3 needs to be, based on the difference between z1 & width (exactly what you do with that difference would take a bit of experimentation, although I have some good ideas). If you loop using your estimate, you need to be sure it can't get stuck in the loop (nor do lots of loops trying to get the "perfect" result), but I suspect you can get away with not using a loop.
Posted on: 2011/4/18 7:50
|
|||
|
||||
|
Slow start program with text size calculation (only first time!)
|
||||
|---|---|---|---|---|
|
Just can't stay away
![]() |
Now I try perfectly fit MyGameName in game window. My code is:
<pre> PROC DrawBoardMenu() SetColour(MakeRGB(col_a1,col_a2,col_a3)) DrawBox (0,0,width,height) -> board clear SetColour(MakeRGB(col_c1,col_c2,col_c3)) z3:=15 REPEAT z3++ -> SetFont('Nimbus Roman No9 L Medium', z3,4) SetFont('Bitstream Vera Sans', z3,2) z1,z2temp:=InfoSizeOfTextL('MyGameName',[])!!INT UNTIL z1 >= (width-10) z3-- -> SetFont('Nimbus Roman No9 L Medium', z3,4) SetFont('Bitstream Vera Sans', z3,2) DrawTextL (0,0,'MyGameName',[],$000000) ENDPROC -> 'end DrawBoardMenu </pre> But first run this code take very long time - near 10 second!!! After closing and run again program work immediatelly. After reset amiga - again I need wait 10 second for first run... How speed-up first run program?
Posted on: 2011/4/16 15:17
|
|||
|
||||
You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.






