I mentioned that a little bit earlier. If you wish to draw to the screen. You will first need to draw to a sprite then draw that sprite onto the screen.
Here's a little example drawing a sprite to the screen. You can move around with the mouse and arrow keys.
Code: Select all
InitEngine3D()
InitSprite()
InitKeyboard()
InitMouse()
Define.f KeyX, KeyY, MouseX, MouseY
OpenScreen(800,600,32,"")
;#### Creating the Sprite and drawing a red box on it.
CreateSprite(1,256,256,#PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(1))
Box(0,0,256,256,RGB(255,0,0))
StopDrawing()
;####
;#### Setting up 3D world.
CreateTexture(1,32,32)
StartDrawing(TextureOutput(1))
Box(0,0,32,32,RGB(0,255,155))
StopDrawing()
CreateMaterial(1,TextureID(1))
CreateTexture(2,32,32)
StartDrawing(TextureOutput(2))
Box(0,0,32,32,RGB(0,0,255))
StopDrawing()
CreateMaterial(2,TextureID(2))
CreateSphere(1,16,16,32)
CreateEntity(1,MeshID(1),MaterialID(1))
CreatePlane(2,1000,1000,1,1,1,1)
CreateEntity(2,MeshID(2),MaterialID(2),0,-40,0)
CreateLight(1,RGB(255,255,255),50,50,50)
CreateCamera(1,0,0,100,100)
MoveCamera(1,0,100,200,#PB_Absolute)
CameraLookAt(1,0,0,0)
CameraBackColor(1,RGB(100,100,100))
WorldShadows(#PB_Shadow_Modulative,600,RGB(200,200,200))
Repeat
If ExamineMouse()
MouseX = -MouseDeltaX()/20
MouseY = -MouseDeltaY()/20
EndIf
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
KeyX = -0.5
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX = 0.5
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = -0.5
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = 0.5
Else
KeyY = 0
EndIf
EndIf
RotateCamera(1, MouseY, MouseX, 0, #PB_Relative)
MoveCamera (1, KeyX, 0, KeyY)
RenderWorld()
;#### You must display the sprite evertime after RenderWorld() otherwise it will be covered up by the 3D world.
DisplayTransparentSprite(1, 400, 300 , 155)
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)