; CreateSkyBox Example ; -------------------- ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,1,-5 light=CreateLight() RotateEntity light,35,-30,0 ; Draw a tiny 2:1 equirectangular sky: gradient, horizon and sun sky_texture=CreateTexture(128,64,1+8+32) SetBuffer TextureBuffer(sky_texture) For y=0 To 63 Color 30+y*2,80+y,180+y Line 0,y,127,y Next Color 255,235,150 Oval 90,8,14,14,True SetBuffer BackBuffer() ; Wrap the image around the whole scene sky=CreateSkyBox(sky_texture) ; A ground slab shows that the sky sits behind everything ground=CreateCube() ScaleEntity ground,4,0.1,4 PositionEntity ground,0,-1,2 EntityColor ground,60,110,50 While Not KeyDown(1) ; Drift the sky slowly - a skybox rotates like any entity TurnEntity sky,0,0.03,0 ; Arrow keys move the camera - look around to see the sky follow 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 Color 255,255,255 Text 0,0,"Arrow keys: move camera Esc: exit" Text 0,20,"sky=CreateSkyBox(sky_texture) The sky follows the camera" Flip Wend End