Page 4 of 4

Posted: Thu Jun 19, 2008 12:07 pm
by fusion_400
Foz wrote:To be honest, having a 30000x300x32 sprite is a Bad Idea anyway.

The correct method would be to chop the string into multiple parts and then only display what you need. For instance, at a minimum have one sprite per letter and then display just the required letters. Given the size of the letters though, it may be better to have a chopping function into say 64x64 pixel sprites and do the stitching on the fly.
ok seems very complicated my programming knowledge is very limited so i doubt i will be able to do that. I just find that purebasic seems to be one of the easiest programming languages. And i really the old scrolling demos that had nice rasterbars and other cool stuff =)

I would love to have sort of a demoengine for purebasic that could do multiple scrollers, movieplaying and also gamma changing completely smooth all at the same time.

Posted: Thu Jun 19, 2008 12:08 pm
by djes
Don't you know grabsprite/clipsprite? I don't have a code to give you by now but I think you can do something with that.

Posted: Thu Jun 19, 2008 12:11 pm
by fusion_400
djes wrote:Don't you know grabsprite/clipsprite? I don't have a code to give you by now but I think you can do something with that.
No i have missed them completely i will try to see what i can do with them though hopefully it can achieve complete smoothness.

One other thing is i wonder why the video overlay in the purebasic only supports playback from MPEG1 movies i mean it's just a simple overlay so the type of codec should not matter to it.

Posted: Fri Jun 20, 2008 12:41 pm
by fusion_400
Ok i have tried to use an image converted to a sprite it is a 1182x74 image with the text "Amiga rulez the world" And this code is working but there is still the stuttering when the movie is enabled this drives me crazy. The stuttering is not continous instead there are sporadic stutters and the cpu usage is no where near maxed when u look at cpu usage history in Windows Task Manager.

The transperency issue does not seem to be a problem either it was automatically transparent ie there was no black background for the textimage

I am going nutz over this i just want it to work without problems.

Code: Select all

InitKeyboard()
InitMovie()
InitSprite()
InitSprite3D()
OpenScreen(1360, 768, 32, "Display System")
LoadFont(0, "Arial", 90)
LoadSprite(0, "Untitled4.bmp", #PB_Sprite_Texture)
CreateSprite3D(0, 0)
LoadMovie(0, "(Fatboy Slim) - Weapon Of Choice.mpg")
text.s = "Display System Version 0.1"

StartDrawing(ScreenOutput())
  DrawingFont(FontID(0))
  tw.l = TextWidth(text)
  ImageText = CreateImage(#PB_Any, tw, TextHeight(text), 32)
StopDrawing()

StartDrawing(ImageOutput(ImageText))
  DrawingMode(#PB_2DDrawing_Transparent)
  DrawingFont(FontID(0))
  
  DrawText(0, 0, text, RGB(255, 255, 255))
 
StopDrawing()


MovieSprite = CreateSprite(1, 352, 240, #PB_Sprite_Texture)
Surface2 = CreateSprite3D(1 , 1)
PlayMovie(0, #PB_Movie_Rendered)

For x = 1024 To -tw Step -2

  RenderMovieFrame(0, MovieSprite)
  
  
  StartDrawing(ScreenOutput())
  
   
    
    ;DrawImage(ImageID(ImageText), x, 200)
    
    ;For k=0 To 255 Step 1
     ; Line(0, 600 - k, 1366, k,RGB(x,x+k+k, 200))
    ;Next
    
  StopDrawing()

 
 
  ClearScreen(RGB(0,50,128))
 y+1
  Start3D()
  DisplaySprite3D(1, 352, 240)
  
 DisplaySprite3D(0, -500+y*2, 500,255)
 ;RotateSprite3D(0, x, 0)
 Stop3D()
  
   FlipBuffers(#PB_Screen_WaitSynchronization)
  ExamineKeyboard()
  If KeyboardPushed(#PB_Key_Escape)
    Break
  EndIf
Next 
IMAGE available below just click on it:

Image

It gets converted to jpg when posted on imagehosting so use UseJPEGImageDecoder() and 8fb634deab.jpg as filename instead in the source.

Posted: Sat Jun 21, 2008 10:34 pm
by Foz
As I said before, it's not difficult - the problem you have is two fold:

1. Images are slow. Use sprites.
<edit: what I said here about MPegs, it's wrong - see my post below about movies>

Now, this was about an Amiga style scroller, so here is my example I put together in the past hour or two:
http://www.shadowtavern.com/source/Scroller.zip

Tips:
1. Only display what you need to - hence a bitmap font, where I display one letter at a time. If it's off screen then I don't bother trying to display it.

2. Render as much as possible up front. It's a lot cheaper to display two rainbow bar sprites rather than rendering 1280 different coloured lines every frame.

Posted: Sun Jun 22, 2008 8:26 am
by fusion_400
Foz wrote:As I said before, it's not difficult - the problem you have is two fold:

1. Images are slow. Use sprites.
2. Mpgs are a PROGRESSIVE technology. That means that if you clear the screen, and then display the current frame, you will only be displaying what previously changed. It's best to forget about doing this.

Now, this was about an Amiga style scroller, so here is my example I put together in the past hour or two:
http://www.shadowtavern.com/source/Scroller.zip

Tips:
1. Only display what you need to - hence a bitmap font, where I display one letter at a time. If it's off screen then I don't bother trying to display it.

2. Render as much as possible up front. It's a lot cheaper to display two rainbow bar sprites rather than rendering 1280 different coloured lines every frame.
Wow really great stuff it looks fantastic. Really oldschool stuff =)

So u mean that it's impossible to make it work with a movie in a decent speed ?

I have tried a software called Blufftitler that managed to display multiple scrollers and displaying any video of choice with full antialiased TTF Fonts. It displayed the scrollers extremely smoothly and it looked fantastic with 6xAntialiasing enabled. Not a hint of slowdown and extremely low cpu usage. I could add plasma and particles effects to and it still ran like a dream with a video running.

Which was pretty neat but i really hoped it could be done here in Purebasic. Atleast the scrolling and video running smoothly together.

I really like Purebasic it's certainly alot simpler then C++ and Java. My programming skills are very limited so thats why i turned to Purebasic to finally maybe get some cool stuff done. As smooth scrolling text in Java seems impossible i have seen some examples and they where all horrible only utilising very simple GDI drawing which has major stuttering and tearing problems.

Posted: Sun Jun 22, 2008 10:28 am
by Kaeru Gaman
i really hoped it could be done here in Purebasic.
sure it could, with some effort to put in.
My programming skills are very limited
well, remember the three ways to success: practice, practice, practice!
i turned to Purebasic to finally maybe get some cool stuff done.
with some practice, effort and time you sure will.
you're just here for a week, have a little patience.
PB maybe quite easy, but it's no click-together-kit, it's a programming language.

don't expect others to have your work done....

Posted: Sun Jun 22, 2008 2:05 pm
by Foz
Here is something else you should know about movies: You're looking at 24-30fps dependent on the movie.

The RenderMovieFrame() takes this into account. Without the movie, you will be running at about 60fps, but when you play the movie, it plays at normal speed, even though you are telling it to render every frame. So, to keep the movie playing normally, RenderMovieFrame() pauses the execution.

To prove it, take a previous section of code:

Code: Select all

For x = 1024 To -tw Step -2

  RenderMovieFrame(0, MovieSprite)
 
 
  StartDrawing(ScreenOutput())
and do this to it:

Code: Select all

For x = 1024 To -tw Step -2

If x%4 = 0
  RenderMovieFrame(0, MovieSprite)
EndIf
 
  StartDrawing(ScreenOutput())
What this does is it will only call RenderMovieFrame() every other frame. So if the movie is at a set 30fps, and you are running at 60, you want to move the text forward twice in between every RenderMovieFrame(). To do this, it takes the X, which is being stepped 2, so to get every other frame, you do some modulus arithmatic, and say, on every x divisable by 4, then RenderMovieFrame(), i.e.

Code: Select all

1024 - RenderMovieFrame()
1022 - Ignore RenderMovieFrame()
1020 - RenderMovieFrame()
1018 - Ignore RenderMovieFrame()
etc
This get's the speed up, but doesn't solve problems like 27.5fps movies - but it's close enough - you will only have to wait a minor amount of time. Instead of waiting 32.5 frames every second, it would only be 5. :)


Now there is a further problem that when rendering the movie, it doesn't play all of it. The problem (I've found) if the fact that Black is classified as transparent. To change this, choose a snorking colour that you wouldn't normally see, such as $FF00FF (hot pink!):

Code: Select all

TransparentSpriteColor(MovieSprite, $FF00FF)
This should render the frames without any trouble.

I've furthered my example to reflect this:
http://www.shadowtavern.com/source/Scro ... 0movie.zip

Posted: Sun Jun 22, 2008 4:51 pm
by fusion_400
Foz wrote:Here is something else you should know about movies: You're looking at 24-30fps dependent on the movie.

The RenderMovieFrame() takes this into account. Without the movie, you will be running at about 60fps, but when you play the movie, it plays at normal speed, even though you are telling it to render every frame. So, to keep the movie playing normally, RenderMovieFrame() pauses the execution.

To prove it, take a previous section of code:

Code: Select all

For x = 1024 To -tw Step -2

  RenderMovieFrame(0, MovieSprite)
 
 
  StartDrawing(ScreenOutput())
and do this to it:

Code: Select all

For x = 1024 To -tw Step -2

If x%4 = 0
  RenderMovieFrame(0, MovieSprite)
EndIf
 
  StartDrawing(ScreenOutput())
What this does is it will only call RenderMovieFrame() every other frame. So if the movie is at a set 30fps, and you are running at 60, you want to move the text forward twice in between every RenderMovieFrame(). To do this, it takes the X, which is being stepped 2, so to get every other frame, you do some modulus arithmatic, and say, on every x divisable by 4, then RenderMovieFrame(), i.e.

Code: Select all

1024 - RenderMovieFrame()
1022 - Ignore RenderMovieFrame()
1020 - RenderMovieFrame()
1018 - Ignore RenderMovieFrame()
etc
This get's the speed up, but doesn't solve problems like 27.5fps movies - but it's close enough - you will only have to wait a minor amount of time. Instead of waiting 32.5 frames every second, it would only be 5. :)


Now there is a further problem that when rendering the movie, it doesn't play all of it. The problem (I've found) if the fact that Black is classified as transparent. To change this, choose a snorking colour that you wouldn't normally see, such as $FF00FF (hot pink!):

Code: Select all

TransparentSpriteColor(MovieSprite, $FF00FF)
This should render the frames without any trouble.

I've furthered my example to reflect this:
http://www.shadowtavern.com/source/Scro ... 0movie.zip
Wow Foz this is amazing exactly what i wanted to see. Rotating movie sprite and bitmap fonts it looks awesome and it works incredibly well no tearing no frame dropouts just total perfection.

This is almost the holy grail sadly the purebasic overlay function only accepts MPEG1 movies.

Posted: Sun Jun 22, 2008 5:35 pm
by Foz
fusion_400 wrote:This is almost the holy grail sadly the purebasic overlay function only accepts MPEG1 movies.
This is untrue. It will only work for definate, every time with mpeg movies - you have to try experimenting with it yourself to see what other codecs will work.

I have tried it with some WMV files and they work almost perfectly - there is a little bit of garbage at the bottom of the sprite about 3-5 pixels worth. On the otherhand, I've tried it with some avi files (NOT DivX or XviD - the original type of avi files) and they work perfectly.

As with all things, it boils down to a "try and see".

Posted: Sun Jun 22, 2008 6:30 pm
by fusion_400
Foz wrote:
fusion_400 wrote:This is almost the holy grail sadly the purebasic overlay function only accepts MPEG1 movies.
This is untrue. It will only work for definate, every time with mpeg movies - you have to try experimenting with it yourself to see what other codecs will work.

I have tried it with some WMV files and they work almost perfectly - there is a little bit of garbage at the bottom of the sprite about 3-5 pixels worth. On the otherhand, I've tried it with some avi files (NOT DivX or XviD - the original type of avi files) and they work perfectly.

As with all things, it boils down to a "try and see".
Ok it was mentioned in the manual i think that only mpeg worked with overlay mode or atleast that worked everytime.

"Not all the codecs are compatible with this function and for now only MPEG files seem to work everytime"

Re:

Posted: Wed May 26, 2010 5:58 pm
by stefff285
hello hello

i took the liberty to take the most approch to amiga classic
scroll text to make my own code without direct x :)

the fonts are fabulous but i have mine so well don't mind
it won't be stolen

thanx a lot for code, i have to learn now

regards

steff

Re: Smooth scrolling text like C64/Amiga how to do it in ba

Posted: Thu May 27, 2010 6:24 am
by dige
The nice scoller demo with movie does not work with DX9 (PB4.50RC1)
With SubSystem DX7 it's fine...

Re: Smooth scrolling text like C64/Amiga how to do it in ba

Posted: Thu May 27, 2010 1:16 pm
by Foz
As stated in the manual about RenderMovieFrame:
Note: this command is only supported on DirectX7 subsystem.

Re: Smooth scrolling text like C64/Amiga how to do it in ba

Posted: Thu May 27, 2010 1:56 pm
by dige
ya right. sorry, but I meant the none working transparency...