Blitz3D+ Command Reference

CameraClsColor camera,red#,green#,blue#

Parameters

camera - camera handle

red# - red value of camera background colour, in the range 0-255
green# - green value of camera background colour, in the range 0-255
blue# - blue value of camera background colour, in the range 0-255

Description

Sets a camera's background colour - the colour its viewport is cleared to before the scene is drawn. Defaults to 0,0,0 (black).

This is the 'sky colour' for simple scenes: a light blue background gives an instant daytime sky without a skybox. If you use fog, set the background to the same colour as CameraFogColor so distant geometry fades seamlessly into the backdrop.

The colour is only visible while colour-buffer clearing is enabled for the camera, which it is by default - if you have turned cls_color off with CameraClsMode, the background colour has no effect.

Each camera has its own background colour, so split-screen views can differ.

See also: CameraClsMode, CameraFogColor, CreateCamera.

Example

; CameraClsColor Example
; ----------------------

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

camera=CreateCamera()
PositionEntity camera,0,1,-5

light=CreateLight()
RotateEntity light,45,45,0

; A spinning pickup coin floats in front of the camera
coin=CreateCylinder()
ScaleEntity coin,1,0.1,1
PositionEntity coin,0,1,0
EntityColor coin,255,200,0

red=0
green=0
blue=64

While Not KeyDown(1)

    ; Hold keys 1/2, 3/4, 5/6 to lower and raise the red, green and blue values
    If KeyDown(2) And red>0 Then red=red-1
    If KeyDown(3) And red<255 Then red=red+1
    If KeyDown(4) And green>0 Then green=green-1
    If KeyDown(5) And green<255 Then green=green+1
    If KeyDown(6) And blue>0 Then blue=blue-1
    If KeyDown(7) And blue<255 Then blue=blue+1

    ; Set the colour the camera clears the screen to each frame
    CameraClsColor camera,red,green,blue

    TurnEntity coin,0,2,0

    ; Arrow keys move the camera
    If KeyDown(200) Then MoveEntity camera,0,0,0.1
    If KeyDown(208) Then MoveEntity camera,0,0,-0.1
    If KeyDown(203) Then TurnEntity camera,0,1,0
    If KeyDown(205) Then TurnEntity camera,0,-1,0

    RenderWorld

    Text 0,0,"Keys 1-6: change red/green/blue   Arrow keys: move camera   Esc: exit"
    Text 0,20,"CameraClsColor camera,"+red+","+green+","+blue

    Flip

Wend

End

Index