Problem with ClsColor

Blitz3D Forums/Blitz3D Beginners Area/Problem with ClsColor

Hi, all!
It seems that I can't get ClsColor working in Blitz3D. Look at the following code (one of the GCUK tutorials slightly amended):

; Setting up ***
; By Paul Gerfen (www.gamecoding.co.uk)

Graphics3D 800,600,32

SetBuffer BackBuffer()

camera=CreateCamera()
CameraViewport camera,0,0,800,600

light=CreateLight()

cube=CreateCube()
PositionEntity cube,0,0,5

ClsColor 255,0,0

While Not KeyHit(1)

ClsColor 255,0,0
Cls

TurnEntity cube,.1,.2,.3

UpdateWorld
RenderWorld

Text 320,500,"First Blitz3D Program"

Flip

Wend
End

The scene's background should be red, right? Well it is black! Am I stupid or what?

Thanks for your help,

Thierry

That's because you are using RenderWorld().

Add this command to your code:
CameraClsMode camera, 0, 1
after these two lines:
camera=CreateCamera()
CameraViewport camera,0,0,800,600

Whenever you are drawing 3D graphics, the default setting is to redraw the entire screen.

Thanks a lot, WolRon!
Cheers,
Thierry

Cls and ClsColor are basically commands for 2D graphics. Use CameraClsColor instead and RenderWorld will automatically clear the screen to the desired colour before rendering.

It seems to me that using both CameraClsColor AND Renderworld will use more processor time (i.e. doing a "clear" twice). Is that going to cause a performance hit, or is it so fast that it is neglible?

CameraClsColor doesn't clear the screen, it only sets the colour to use when RenderWorld does.