Hello Fred + Samuel,
You are right that ClearScreen doesn't make sense if a Camera is filling the whole screen.
But what if it doesn't fill the whole screen? The help file says:
If a camera is created with a height of 50% then it will always fill 50% of the height of the screen, irrespective of whether you use a screen which is 640*480 or 1600*1200.
It also says:
Once the RenderWorld() function has been performed, it's possible to use regular 2D functions like DisplaySprite() to display 2D sprites over the 3D world.
What if you want to render small screens (like a multi-player console game) but also draw a GUI using 2D sprites? ClearScreen doesn't seem to work if Engine3D is used... example:
Code: Select all
; Create windowed screen
InitEngine3D()
InitSprite()
OpenWindow(0, 0, 0, 640, 480, "", #PB_Window_ScreenCentered|#PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(0), 0, 0, WindowWidth(0), WindowHeight(0))
; Create two cameras
CreateCamera(0, 0, 0, 50, 50)
CameraBackColor(0, $FF0000)
CreateCamera(1, 50, 50, 50, 50)
CameraBackColor(1, $0000FF)
; Create 2D sprite
CreateSprite(0, 32, 32)
If (StartDrawing(SpriteOutput(0)))
Box(0, 0, OutputWidth(), OutputHeight(), $00FF00)
Box(OutputWidth()/4, OutputWidth()/4, OutputWidth()/2, OutputHeight()/2, $FF00FF)
StopDrawing()
EndIf
Repeat
Event = WindowEvent()
While (Event)
If (Event = #PB_Event_CloseWindow)
Done = #True
EndIf
Event = WindowEvent()
Wend
; ClearScreen doesn't do anything here
ClearScreen($FFFFFF)
RenderWorld()
; doesn't do anything here either
ClearScreen($FFFFFF)
; we can draw sprites around the cameras, but not clear them
DisplaySprite(0, 320 + Cos(ElapsedMilliseconds()/777)*160 - 16, 240 + Sin(ElapsedMilliseconds()/1000)*120 - 16)
; one more try, doesn't clear the sprite
ClearScreen($FFFFFF)
FlipBuffers()
Until Done
With PB 5.21 LTS on Windows 7 I see a moving green sprite on a black background, but it never gets erased by any of the white ClearScreen calls.
Thanks for asking about this!