Unable to draw to screen with engine3D

Just starting out? Need help? Post your questions and find answers here.
Nituvious
Addict
Addict
Posts: 1033
Joined: Sat Jul 11, 2009 4:57 am
Location: United States

Unable to draw to screen with engine3D

Post 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.
▓▓▓▓▓▒▒▒▒▒░░░░░
Fred
Administrator
Administrator
Posts: 18553
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Unable to draw to screen with engine3D

Post by Fred »

You can not store ScreenOutput() (or any xxxOutput()) value, you have to put it in the StartDrawing() call.
Nituvious
Addict
Addict
Posts: 1033
Joined: Sat Jul 11, 2009 4:57 am
Location: United States

Re: Unable to draw to screen with engine3D

Post 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
▓▓▓▓▓▒▒▒▒▒░░░░░
Nituvious
Addict
Addict
Posts: 1033
Joined: Sat Jul 11, 2009 4:57 am
Location: United States

Re: Unable to draw to screen with engine3D

Post by Nituvious »

I think I fixed the issue by setting a subsystem
▓▓▓▓▓▒▒▒▒▒░░░░░
LuCiFeR[SD]
666
666
Posts: 1033
Joined: Mon Sep 01, 2003 2:33 pm

Re: Unable to draw to screen with engine3D

Post 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
Last edited by LuCiFeR[SD] on Mon Aug 05, 2013 10:44 pm, edited 1 time in total.
Nituvious
Addict
Addict
Posts: 1033
Joined: Sat Jul 11, 2009 4:57 am
Location: United States

Re: Unable to draw to screen with engine3D

Post 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?
▓▓▓▓▓▒▒▒▒▒░░░░░
LuCiFeR[SD]
666
666
Posts: 1033
Joined: Mon Sep 01, 2003 2:33 pm

Re: Unable to draw to screen with engine3D

Post 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.
Last edited by LuCiFeR[SD] on Mon Aug 05, 2013 10:43 pm, edited 1 time in total.
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: Unable to draw to screen with engine3D

Post 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.
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: Unable to draw to screen with engine3D

Post by Olliv »

@Lucifer

Your ClearScreen() is useless. CameraBackColor() replaces it...

What? Away what? Go away? Me? I go away....
LuCiFeR[SD]
666
666
Posts: 1033
Joined: Mon Sep 01, 2003 2:33 pm

Re: Unable to draw to screen with engine3D

Post 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.
Nituvious
Addict
Addict
Posts: 1033
Joined: Sat Jul 11, 2009 4:57 am
Location: United States

Re: Unable to draw to screen with engine3D

Post by Nituvious »

Very cool! Thank you!
▓▓▓▓▓▒▒▒▒▒░░░░░
Post Reply