• Welcome to Dark Bit Factory & Gravity.
 

Bitmap Sinusscroller with low FPS :( Please help ..

Started by DeXtr0, July 14, 2007

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Maxx

The text appears at bottom but no scroller  ???
Proud Member Of Dawn Creations
Challenge Trophies Won:

DeXtr0

This will be a hard on to track down.
@Maxx, can you install the latest directX, just to be sure that this is not the problem ?

I have no clue why the scroller does not appear .. all tips are welcome..

Ow wait, does anybody of you has Windows Vista maybe ?
I have not tested in on Vista, I don't have a vista @ home or @ work

.DeXtr0

Shockwave

Quote from: DeXtr0 on July 18, 2007
@Benny: I create, before starting the intro a lot of sprites dynamically (based on the length of the sinusscroller). This needs a lot of memory. How much memory you have in your system ? And do you have directX 9.0c installed ? This is what I need .. <= I just check, I need to look why it crashes....

Aaaarrgh! You mean you precalculate the whole scrolltext intro sprites? Erk :D
That wasn't quite what I meant when I was advising how to make it.

You only need to chop each letter into strips once!

So for the letter A you maight chop up 32 slices, if your text string is AAAAAAAAAA it doesn't mean that you need 320 slices, you can re-use the 32 10 times.

Maybe this explaination I am giving you is not good.. Hmm. Ok.

If you were making a game like Space invaders, say there were 5 different types of invader, you'd re-use the same invaders and draw them in different places on the screen to make your attack wave.

Same thing goes for the sine scroller. Your font could be stored in memory like the image I've attached and you just chop strips out of it as you need them.

The main point is that you only draw once per frame, drawing twice was costing you the speed.
Shockwave ^ Codigos
Challenge Trophies Won:

DeXtr0

Hey shockwave,

I think i misunderstood you, you are right ;)
What I did was I created 1 sprite with the whole bitmaptext, then sliced it into 1pixel width sprites and draw those
However this results in over 3000 sprites when it's a large text  ;)

I'll restart coding again then.. Pitty since it was very fast :)

I'll drop a note when i'm ready again..

Cheers,
DeXtr0

benny!

@DexTro:

Well, to be honest - I do not know much about sine scrollers - and I have to admit that
I am didnt code in purebasic for some months. But I have done the following little test
that might help you ...

(Note: Now there is only one sprite containing the whole text - change this so that every
letter is represented by a single sprite and add the sinus sprite clipping on every letter sprite)




; little sinus scroll example by benny!weltenkonstrukteur.de

If InitSprite() = 0 Or InitKeyboard() = 0
  MessageRequester("Error", "Can't open DirectX 7 or later", 0)
  End
EndIf

If OpenScreen(640, 480, 16, "SinusScroll")

 
  ; Creating test scrolly
  CreateSprite( 13, 128, 128, #PB_Sprite_Memory )
  LoadFont(1, "Arial", 32 ) 
  StartDrawing( SpriteOutput( 13 ) )
    BackColor( RGB(0,0,0) )
    FrontColor( RGB(255,255,255) )
    DrawText(1,1,"TEST 123")
  StopDrawing()
   
   
  sin.f = 0.0
  Repeat
   
    FlipBuffers()   
    ClearScreen(RGB(0,0,0))       
   
    For i=1 To 128
      sin.f + 0.0018
      ClipSprite( 13, i, 1, 1, 32 )
      DisplaySprite(13, 100+i, 200+Sin(sin.f-i*0.1)*( i/5) )     
    Next i
 
    Delay(1)
   
    ExamineKeyboard()
  Until KeyboardPushed(#PB_Key_Escape)
 
Else
  MessageRequester("Error", "Can't open a 640*480 - 16 bit screen !", 0)
EndIf

End   
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

DeXtr0

Hey Benny!

Super example and yes your "note" was indeed the issue that shockwave explained.
I'm going to recoded it again :)

You example is indeed a very good one.. I did that before but it was too slow if you have to clip 800x in a loop (screensize 800x600).
That's why I thought of clipping all before the real code starts and that is what i'm going to do now..

1000x thanks,
DeXtr0

benny!

@DexTr0:

No problem, mate. Glad that the code was helpful. Good luck with recoding it.
Looking forward to see the new version !!!
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Jim

Challenge Trophies Won:

DeXtr0

Hey Jim,

what FPS did you get and how many memory you have in your system ?

Regards,
DeXt0

Stonemonkey

Works ok here too, 230-240 fps,   winXP + amd64-3200 + 1Gb + X1650.

DeXtr0

Super Stonemonkey ,

Thanks for testing.. However I will recode it again  ;D

Cheers,
DeXtr0

Jim

About 400fps.  2Gb RAM, 256Mb video :P

Jim
Challenge Trophies Won:

DeXtr0

That's not bad, pretty fast even :)

But ok here I go, recoding again..
I think I'm going to walk like a sinus soon  :D

va!n

@Dextro:
Latest version and its speed improvement looks nice... However seems, fps slow a bit down when full screen is filled with the sinus scroller. but ist still fast enough.

However, i dont know how your latest source may look like... In your first source i saw a lot of things you could optimize.... i tried to give some tips and i think some things has been changed now... but here are just some little things that should help too...


Procedure.f DXP_Sinus(Angle.f)                       
  ProcedureReturn Sin(Angle*(2*3.14159265/360))
EndProcedure

Change to.

Procedure.f DXP_Sinus(Angle.f)                       
  ProcedureReturn Sin(Angle*0.0174532925)     ; 0.0174532925 == (2*3.14159265/360))
EndProcedure



StartDrawing(ScreenOutput())
 
    FrontColor(FrontColor)
    BackColor(BackColor)
   
    If FontID<>0: DrawingFont(FontID) : EndIf
   
    DrawText(x, y, Text.s)
   
  StopDrawing()

change to:

StartDrawing(ScreenOutput())
 
    If FontID<>0: DrawingFont(FontID) : EndIf
   
    DrawText(x, y, Text.s, FrontColor, BackColor)      ; should be faster! (dont use Front-/BackColor() commands ^^)
   
StopDrawing()

- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

DeXtr0

Hey Va!n,

while you were probably rewriting me some tips I rewrote, together with my co-coder eNeRGy, our whole routine based on the "golden tip" from shock.

Could you all please recheck this zip file and reply with the fps ?
This is the best we can get I think.

If it's still too slow I will recheck your code va!n and check if we have missed some things

Cheers and thanks everybody for all help
DeXtr0

Shockwave

A pretty consistent 250 - 254 fps here :)
Nice work.
Shockwave ^ Codigos
Challenge Trophies Won:

DeXtr0

Yeahhhhhhhhhhh baby  :updance:

This is finally a good approach..

I hope it runs on everybody's PC.

Now I can add speed effects and a stop too :)

Thanks shock

benny!

Awesome work. Constant 164fps and scroller runs very smooth and is not too slow IMHO.

Well done and congrats !!!
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Shockwave

Use a different font though ;) That one comes with OSDM.
Shockwave ^ Codigos
Challenge Trophies Won:

Maxx

Proud Member Of Dawn Creations
Challenge Trophies Won: