Author Topic: Bitmap Sinusscroller with low FPS :( Please help ..  (Read 3965 times)

0 Members and 1 Guest are viewing this topic.

Offline Maxx

  • C= 64
  • **
  • Posts: 51
  • Karma: 9
    • View Profile
The text appears at bottom but no scroller  ???
Proud Member Of Dawn Creations
Challenge Trophies Won:

Offline DeXtr0

  • C= 64
  • **
  • Posts: 79
  • Karma: 3
  • Proud member of dAWN
    • View Profile
    • dAWN Creations
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
« Last Edit: July 18, 2007 by DeXtr0 »

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 16788
  • Karma: 439
  • evil/good
    • View Profile
    • My Homepage
@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:

Offline DeXtr0

  • C= 64
  • **
  • Posts: 79
  • Karma: 3
  • Proud member of dAWN
    • View Profile
    • dAWN Creations
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

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4130
  • Karma: 223
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
@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)


Code: [Select]

; 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:

Offline DeXtr0

  • C= 64
  • **
  • Posts: 79
  • Karma: 3
  • Proud member of dAWN
    • View Profile
    • dAWN Creations
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

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4130
  • Karma: 223
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
@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:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5098
  • Karma: 380
    • View Profile
Worked for me on Vista.

Jim
Challenge Trophies Won:

Offline DeXtr0

  • C= 64
  • **
  • Posts: 79
  • Karma: 3
  • Proud member of dAWN
    • View Profile
    • dAWN Creations
Hey Jim,

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

Regards,
DeXt0

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1215
  • Karma: 92
    • View Profile
Works ok here too, 230-240 fps,   winXP + amd64-3200 + 1Gb + X1650.

Offline DeXtr0

  • C= 64
  • **
  • Posts: 79
  • Karma: 3
  • Proud member of dAWN
    • View Profile
    • dAWN Creations
Super Stonemonkey ,

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

Cheers,
DeXtr0

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5098
  • Karma: 380
    • View Profile
About 400fps.  2Gb RAM, 256Mb video :P

Jim
Challenge Trophies Won:

Offline DeXtr0

  • C= 64
  • **
  • Posts: 79
  • Karma: 3
  • Proud member of dAWN
    • View Profile
    • dAWN Creations
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
« Last Edit: July 20, 2007 by DeXtr0 »

Offline va!n

  • Pentium
  • *****
  • Posts: 1334
  • Karma: 106
    • View Profile
    • http://www.secretly.de
@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...

Code: [Select]
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

Code: [Select]
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()
Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows7 x64
http://www.secretly.de
Challenge Trophies Won:

Offline DeXtr0

  • C= 64
  • **
  • Posts: 79
  • Karma: 3
  • Proud member of dAWN
    • View Profile
    • dAWN Creations
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

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 16788
  • Karma: 439
  • evil/good
    • View Profile
    • My Homepage
A pretty consistent 250 - 254 fps here :)
Nice work.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline DeXtr0

  • C= 64
  • **
  • Posts: 79
  • Karma: 3
  • Proud member of dAWN
    • View Profile
    • dAWN Creations
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

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4130
  • Karma: 223
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
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:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 16788
  • Karma: 439
  • evil/good
    • View Profile
    • My Homepage
Use a different font though ;) That one comes with OSDM.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Maxx

  • C= 64
  • **
  • Posts: 51
  • Karma: 9
    • View Profile
166 this time nice work :) :buddies:
Proud Member Of Dawn Creations
Challenge Trophies Won: