Posted: Wed Jun 18, 2008 2:29 pm
additionally, on a screen better use a Sprite than an Image.
http://www.purebasic.com
https://www.purebasic.fr/english/
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
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: 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
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.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
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.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
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.
use SpriteOutput() instead of ImageOutput()Kaeru Gaman wrote:draw your chars to a sprite not to an image right in the beginning.
Exactly i have tried with SpriteOutput but it does not work.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".