Page 3 of 4

Posted: Wed Jun 18, 2008 2:29 pm
by Kaeru Gaman
additionally, on a screen better use a Sprite than an Image.

Posted: Wed Jun 18, 2008 2:33 pm
by Foz
You had missed a number of things, including outputting to the screen.

It's really not that hard:

Code: Select all

InitSprite()
InitKeyboard()
OpenScreen(1024, 768, 32, "Display System")
LoadFont(0,"Arial",72)
text.s = "Display System Version 0.1"

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


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

For x = 1024 To -tw Step -1
  StartDrawing(ScreenOutput())
    DrawImage(ImageID(ImageToDrawOn), x, 200)
  StopDrawing()
  
  FlipBuffers()
  
  ExamineKeyboard()
  If KeyboardPushed(#PB_Key_Escape)
    Break
  EndIf
Next

Posted: Wed Jun 18, 2008 3:21 pm
by Derek
Also use a drawingfont(fontid(0)) in the loop to change the text size.

Posted: Wed Jun 18, 2008 3:57 pm
by Foz
Good point, example updated.

Posted: Wed Jun 18, 2008 4:46 pm
by fusion_400
I have gotten this to work now without flickering due to using ClearScreen($402010).

But the scroller is still slow and the movie gets played in the background instead of the foreground and there is no transperency either with the text just white text and black background.

Also about converting the image to a sprite how is this done maybe this will speed up things ?

Code: Select all

InitKeyboard()
InitMovie()
InitSprite()
InitSprite3D()
OpenScreen(1024, 768, 32, "Display System")
LoadFont(0,"Arial",130)
text.s = "Display System Version 0.1"
LoadMovie(0, "(Fatboy Slim) - Weapon Of Choice.mpg")
Surface = CreateSprite(0, 256, 256, #PB_Sprite_Texture)
Surface2 = CreateSprite3D(0 , 0)
PlayMovie(0, #PB_Movie_Rendered)

StartDrawing(ScreenOutput())

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


StartDrawing(ImageOutput(ImageToDrawOn))

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

For x = 1024 To -tw Step -1
  StartDrawing(ScreenOutput())
 
    DrawImage(ImageID(ImageToDrawOn), x, 200)
  StopDrawing()
   
  FlipBuffers()
  ClearScreen($402010)
 Start3D() 

      RenderMovieFrame(0,Surface)
    DisplaySprite3D(0, 200, 200, x)
    ZoomSprite3D(0, x, x)
    RotateSprite3D(0, x, 0)
    
  
  Stop3D()
  ExamineKeyboard()
  If KeyboardPushed(#PB_Key_Escape)
    Break
  EndIf
Next

[/code]

Posted: Wed Jun 18, 2008 5:07 pm
by Kaeru Gaman
> the movie gets played in the background instead of the foreground

mind the order of your commands.
first clear the screen, then output back to fore, then flip.

> Also about converting the image to a sprite how is this done

draw your chars to a sprite not to an image right in the beginning.

Posted: Wed Jun 18, 2008 5:18 pm
by fusion_400
If i put clearscreen at the top i get the flickering.

I also tried to move around the start3d function but it does not matter where i move it still is not displayed in the foreground.

And if i move flip buffers down below stop3d i get flickering text again.

I also tried to convert chars to a sprite but i don't even get a error message or even a black screen.

I hope somebody can help me with this.

Code: Select all

InitKeyboard()
InitMovie()
InitSprite()
InitSprite3D()
OpenScreen(1024, 768, 32, "Display System")
LoadFont(0,"Arial",130)
text.s = "Display System Version 0.1"
LoadMovie(0, "(Fatboy Slim) - Weapon Of Choice.mpg")
Surface = CreateSprite(0, 256, 256, #PB_Sprite_Texture)
Surface2 = CreateSprite3D(0 , 0)
PlayMovie(0, #PB_Movie_Rendered)


StartDrawing(ScreenOutput())

  DrawingFont(FontID(0))
  tw.l = TextWidth(text)
  ImageToDrawOn = CreateSprite(0, tw, TextHeight(text),0)
  
StopDrawing()

 
StartDrawing(SpriteOutput(ImageToDrawOn))

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

For x = 1024 To -tw Step -1
  StartDrawing(ScreenOutput())
 
    DisplaySprite(SpriteID(ImageToDrawOn), 200, 200)
  StopDrawing()
    
 ClearScreen($402010)
   Start3D() 

      RenderMovieFrame(0,Surface)
    DisplaySprite3D(0, 200, 200, x)
    ZoomSprite3D(0, x, x)
    RotateSprite3D(0, x, 0)
    
  
  Stop3D()
  
FlipBuffers()

  ExamineKeyboard()
  If KeyboardPushed(#PB_Key_Escape)
    Break
  EndIf
Next

Posted: Wed Jun 18, 2008 10:03 pm
by Foz
You can't put RenderMovieFrame() in a Start block.

This is a little closer, but you'll need to deal with transparancy:

Code: Select all

InitKeyboard()
InitMovie()
InitSprite()

OpenScreen(1024, 768, 32, "Display System")
LoadFont(0, "Arial", 130)
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()

LoadMovie(0, "C:\Documents\Projects\Scroller Test\a_movie2.mpeg")
MovieSprite = CreateSprite(#PB_Any, 352, 240)
PlayMovie(0, #PB_Movie_Rendered)

For x = 1024 To -tw Step -1
  RenderMovieFrame(0, SpriteID(MovieSprite))
  DisplaySprite(MovieSprite, 200, 200)
  
  StartDrawing(ScreenOutput())
    DrawImage(ImageID(ImageText), x, 200)
  StopDrawing()
  
  FlipBuffers(#PB_Screen_WaitSynchronization)
  
  ExamineKeyboard()
  If KeyboardPushed(#PB_Key_Escape)
    Break
  EndIf
Next

Posted: Thu Jun 19, 2008 5:28 am
by fusion_400
Foz wrote:You can't put RenderMovieFrame() in a Start block.

This is a little closer, but you'll need to deal with transparancy:

Code: Select all

InitKeyboard()
InitMovie()
InitSprite()

OpenScreen(1024, 768, 32, "Display System")
LoadFont(0, "Arial", 130)
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()

LoadMovie(0, "C:\Documents\Projects\Scroller Test\a_movie2.mpeg")
MovieSprite = CreateSprite(#PB_Any, 352, 240)
PlayMovie(0, #PB_Movie_Rendered)

For x = 1024 To -tw Step -1
  RenderMovieFrame(0, SpriteID(MovieSprite))
  DisplaySprite(MovieSprite, 200, 200)
  
  StartDrawing(ScreenOutput())
    DrawImage(ImageID(ImageText), x, 200)
  StopDrawing()
  
  FlipBuffers(#PB_Screen_WaitSynchronization)
  
  ExamineKeyboard()
  If KeyboardPushed(#PB_Key_Escape)
    Break
  EndIf
Next
Thanks alot yes this certainly is a step in the right direction but the text generation seems slow when the movie is on and if i try to speed it up it just gets jerky.

Posted: Thu Jun 19, 2008 6:27 am
by Foz
it's slow for two reasons:
1. It's waiting for the vsync. This would be 60hz for most people.
2. It's only moving the text on 1 pixel at a time. (step -1)

These two reasons combined is why it's slow - it's only doing 60 pixels a second.

The vsync gives constant speed, so you'll need to play with the pixel jump - step -2, step -3, etc

Posted: Thu Jun 19, 2008 6:34 am
by fusion_400
Foz wrote:it's slow for two reasons:
1. It's waiting for the vsync. This would be 60hz for most people.
2. It's only moving the text on 1 pixel at a time. (step -1)

These two reasons combined is why it's slow - it's only doing 60 pixels a second.

The vsync gives constant speed, so you'll need to play with the pixel jump - step -2, step -3, etc
Yes that's exactly what i changed but it stutters badly. It moves the text faster but it's just not smooth in any way it's basically dropping frames to keep up.

How do i get the text to display as a sprite instead of an image ? Maybe this will speed up things.

And i have a very solid C2D@2.8Ghz and 2GB ram and Radeon X1950Pro so the hardware should be able to handle it without any skipping or dramatic slowdown. I mean the movie is always running smoothly but everything else gets slowed down when it's enabled. And a simple MPEG1 is just not very processor intensive when u have a C2D.

The text is very smooth at high speeds when the movie is disabled. Thats why i think that maybe it's a good thing to try and convert the text to sprite instead of text to image but i don't know how to do that.

Posted: Thu Jun 19, 2008 9:52 am
by Kaeru Gaman
fusion_400 wrote:How do i get the text to display as a sprite instead of an image ?
...
convert the text to sprite instead of text to image but i don't know how to do that.
Kaeru Gaman wrote:draw your chars to a sprite not to an image right in the beginning.
use SpriteOutput() instead of ImageOutput()

Posted: Thu Jun 19, 2008 10:19 am
by Foz
Using SpriteOutput didn't work if you used his example above.

I suspect that it is something to do with the sheer size of the "sprite".

Posted: Thu Jun 19, 2008 11:43 am
by fusion_400
Foz wrote:Using SpriteOutput didn't work if you used his example above.

I suspect that it is something to do with the sheer size of the "sprite".
Exactly i have tried with SpriteOutput but it does not work.

Posted: Thu Jun 19, 2008 11:49 am
by Foz
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.