I've read that it's better to draw to a sprite and then display that sprite on the screen instead of directly drawing to the screen.
Here's a basic example showing the current frames per second using a sprite.
Code: Select all
Enumeration
#Window
#Camera
#Mesh
#Entity
#Light
#Font
#Sprite
EndEnumeration
If InitEngine3D() = 0
End
EndIf
If InitSprite() = 0
End
EndIf
If InitKeyboard() = 0
End
EndIf
ExamineDesktops()
Define.i DesktopW = 800
Define.i DesktopH = 600
Define.i Event
Define.i Quit
Define.i FPS
If OpenWindow(#Window, 0, 0, DesktopW, DesktopH, "Frames Per Second", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If OpenWindowedScreen(WindowID(#Window), 0, 0, DesktopW, DesktopH, 0, 0, 0)
CreateSphere(#Mesh, 2, 64, 32)
CreateEntity(#Entity, MeshID(#Mesh), #PB_Material_None)
CreateCamera(#Camera, 0, 0, 100, 100)
MoveCamera(#Camera, 0, 0, 10, #PB_Absolute)
CameraLookAt(#Camera,0,0,0)
CameraBackColor(#Camera,RGB(20,20,20))
CreateLight(#Light, RGB(255,255,255), 10, 10, 10)
LoadFont(#Font, "Times New Roman", 20, #PB_Font_Bold)
CreateSprite(#Sprite, 128, 64)
StartDrawing(SpriteOutput(#Sprite))
DrawingMode(#PB_2DDrawing_AlphaChannel)
Box(0, 0, 50, 50)
DrawingMode(#PB_2DDrawing_Transparent)
DrawingFont(FontID(#Font))
DrawText(0, 0, "FPS : 60", RGB(255,255,255))
StopDrawing()
Repeat
Event = WindowEvent()
If ExamineKeyboard()
If KeyboardReleased(#PB_Key_Escape)
Quit = 1
EndIf
EndIf
RenderWorld()
StartDrawing(SpriteOutput(#Sprite))
Box(0, 0, 128, 64, RGB(0,0,0))
DrawingMode(#PB_2DDrawing_AlphaChannel)
Box(0, 0, 128, 64)
DrawingMode(#PB_2DDrawing_Transparent)
DrawingFont(FontID(#Font))
FPS = Engine3DStatus(#PB_Engine3D_CurrentFPS)
DrawText(0, 0, "FPS : "+Str(FPS), RGB(255,255,255))
StopDrawing()
DisplayTransparentSprite(#Sprite, 0, 0)
FlipBuffers()
Until Quit = 1 Or Event = #PB_Event_CloseWindow
EndIf
EndIf
End