Page 1 of 1
Unable to draw to screen with engine3D
Posted: Mon Aug 05, 2013 6:46 am
by Nituvious
Can someone tell enlighten me why I get the following error:
[ERROR] The specified output is NULL (0 value)
Code:
Code: Select all
Procedure RenderScreen()
Define.l s = ScreenOutput()
RenderWorld()
ClearScreen(0)
StartDrawing(s) ; error
DrawText(15, 15, "Test", RGB(0, 250, 250))
StopDrawing()
FlipBuffers()
EndProcedure
I have a screen active. Meshes display without any problems, but I can't draw to the screen.
Re: Unable to draw to screen with engine3D
Posted: Mon Aug 05, 2013 8:46 am
by Fred
You can not store ScreenOutput() (or any xxxOutput()) value, you have to put it in the StartDrawing() call.
Re: Unable to draw to screen with engine3D
Posted: Mon Aug 05, 2013 9:03 am
by Nituvious
Fred wrote:You can not store ScreenOutput() (or any xxxOutput()) value, you have to put it in the StartDrawing() call.
I get the same error when I call it directly from StartDrawing
Re: Unable to draw to screen with engine3D
Posted: Mon Aug 05, 2013 10:14 am
by Nituvious
I think I fixed the issue by setting a subsystem
Re: Unable to draw to screen with engine3D
Posted: Mon Aug 05, 2013 1:36 pm
by LuCiFeR[SD]
@Fred,
ScreenOutput() Does not work with Ogre enabled. I don't know if this is by design or a bug?, but you will always get an IMA with it if you try.
@Nituvious so the easiest way to get around this is to use sprites. Changing subsystems is just going to mask a flaw in your program. it is a lot better if you can get it to work correctly on all subsystems don't you think?
Code: Select all
EnableExplicit
Define.i Event,Exit
InitEngine3D()
InitSprite()
InitKeyboard()
OpenWindow(0,0,0,800,600,"hello",#PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(0),0,0,800,600)
CreateCamera(0,0,0,800,600)
CreateSprite(0,60,20)
CreateSprite(1,ScreenWidth(),20)
StartDrawing(SpriteOutput(0))
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(0, 0, "Test")
StopDrawing()
;- Main loop
Repeat
;- All 3D commands must be placed before RenderWorld()!
;
RenderWorld()
;All 2D commands to be placed AFTER RenderWorld()
;
DisplayTransparentSprite(0,0,0,255,RGB(Random(255),Random(255),Random(255)))
DisplayTransparentSprite(0,Random(ScreenWidth()),Random(ScreenHeight()),255,RGB(Random(255),Random(255),Random(255)))
DisplayTransparentSprite(1,0,ScreenHeight()-SpriteHeight(1),255,RGB(Random(255),Random(255),Random(255)))
StartDrawing(SpriteOutput(1))
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(0, 0, "Mary had a little lamb, she tied it to a pylon. 40000 volts shot up its ass and turned its wool to nylon")
StopDrawing()
;}
;{ Event loop
;- Event loop
; We check the events until ALL are processed.
; this is very important!
;
Repeat
Event=WindowEvent()
Select Event
Case #PB_Event_CloseWindow
Exit=#True
EndSelect
Until Event=#False
;}
;{ Check Keyboard
;-Check Keyboard
;
If ExamineKeyboard()
If KeyboardReleased(#PB_Key_Escape)
Exit=#True
EndIf
EndIf
;}
FlipBuffers()
CameraBackColor(0,$000000)
Until Exit=#True
End
Edit to fix bug
Re: Unable to draw to screen with engine3D
Posted: Mon Aug 05, 2013 4:00 pm
by Nituvious
I'm looking to draw some text to the screen that with data that can change given use input. Using the method described by you the text will just draw over the sprite again.
Is there a simple way to redraw text over a sprite without artifacts or whatever they're called?
Maybe something like filled rectangle of transparent color -> background sprite/image -> text?
Re: Unable to draw to screen with engine3D
Posted: Mon Aug 05, 2013 4:12 pm
by LuCiFeR[SD]
Nituvious wrote:I'm looking to draw some text to the screen that with data that can change given use input. Using the method described by you the text will just draw over the sprite again.
Is there a simple way to redraw text over a sprite without artifacts or whatever they're called?
Maybe something like filled rectangle of transparent color -> background sprite/image -> text?
press 1 or 2 to change text.
Code: Select all
EnableExplicit
Define.i Event,Exit
InitEngine3D()
InitSprite()
InitKeyboard()
OpenWindow(0,0,0,800,600,"hello",#PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(0),0,0,800,600)
CreateCamera(0,0,0,800,600)
CreateSprite(1,ScreenWidth(),20)
;- Main loop
Repeat
;- All 3D commands must be placed before RenderWorld()!
;
RenderWorld()
;All 2D commands to be placed AFTER RenderWorld()
;
DisplaySprite(1,0,ScreenHeight()-SpriteHeight(1))
;}
;{ Event loop
;- Event loop
; We check the events until ALL are processed.
; this is very important!
;
Repeat
Event=WindowEvent()
Select Event
Case #PB_Event_CloseWindow
Exit=#True
EndSelect
Until Event=#False
;}
;{ Check Keyboard
;-Check Keyboard
;
If ExamineKeyboard()
If KeyboardReleased(#PB_Key_Escape)
Exit=#True
EndIf
If KeyboardReleased(#PB_Key_1)
StartDrawing(SpriteOutput(1))
Box(0,0,SpriteWidth(1),SpriteHeight(1),$000000)
DrawText(0, 0, "Mary had a little lamb, she tied it to a pylon")
StopDrawing()
EndIf
If KeyboardReleased(#PB_Key_2)
StartDrawing(SpriteOutput(1))
Box(0,0,SpriteWidth(1),SpriteHeight(1),$000000)
DrawText(0, 0, "40000 volts shot up its ass and turned its wool to nylon")
StopDrawing()
EndIf
EndIf
;}
FlipBuffers()
CameraBackColor(0,$000000)
Until Exit=#True
End
Edit to fix bug.
Re: Unable to draw to screen with engine3D
Posted: Mon Aug 05, 2013 4:48 pm
by Olliv
Fred said: "or any xxxoutput()"
I do know who is this Fred but this man is wrong...
Doops... Sorry!
As says LuCiFer[SD], I agree totally. I merge foreground with sprite exactly as LuCiFeR uses in the main loop and the background on 3D rendering on a very old computer. I update a whole image sized 256x256 with 65536 plotings depending of the position of the mouse. It's in real time and I am surprised by the speed. Small difference, I work on fullscreen.
Re: Unable to draw to screen with engine3D
Posted: Mon Aug 05, 2013 5:00 pm
by Olliv
@Lucifer
Your ClearScreen() is useless. CameraBackColor() replaces it...
What? Away what? Go away? Me? I go away....
Re: Unable to draw to screen with engine3D
Posted: Mon Aug 05, 2013 10:37 pm
by LuCiFeR[SD]
Olliv wrote:@Lucifer
Your ClearScreen() is useless. CameraBackColor() replaces it...
What? Away what? Go away? Me? I go away....
hehe, I guess everybody makes mistakes?

Thanks Olliv for pointing out the error. Post above edited to reflect the change.
Re: Unable to draw to screen with engine3D
Posted: Wed Aug 07, 2013 4:40 pm
by Nituvious
Very cool! Thank you!