RenderWorld [tween#]
Parameters
| tween# (optional) - interpolation between captured and current entity states, in the range 0 to 1; 1 (default) |
Description
|
Renders the current scene to the backbuffer. Every camera that is not hidden by HideEntity and does not have a CameraProjMode of 0 is rendered, each into the rectangle defined by its CameraViewport. RenderWorld only draws - follow it with Flip to show the frame, and call UpdateWorld beforehand for animation and collisions. Those four calls (UpdateWorld, RenderWorld, 2D overlay drawing, Flip) are the heart of a Blitz3D main loop. (In Extended mode, RenderWorldToCanvas can also render a world through a camera onto a GUI canvas.) The optional tween parameter is only needed in conjunction with CaptureWorld. CaptureWorld stores the 'old' position, rotation, scale, alpha and colour of each entity; a tween value below 1 renders each entity interpolated between its captured state and its current state. A tween of 0 renders entities entirely at their captured state, and 1 entirely at their current state. Tweening lets you render more than one frame per game logic update while keeping motion smooth: run your logic at a fixed rate, and between logic updates render with a tween equal to the fraction of the logic step that has elapsed. A popular alternative is delta timing - scaling each frame's movement by the time the frame took. Render tweening is an advanced technique and entirely optional; see the castle demo in the samples for a working example. See also: CaptureWorld, UpdateWorld, CameraViewport, CameraProjMode. |
Example
; RenderWorld Example ; ------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,1,-5 light=CreateLight() RotateEntity light,45,45,0 ; A spinning cone so each rendered frame is different cone=CreateCone(16) PositionEntity cone,0,1,0 EntityColor cone,255,100,0 While Not KeyDown(1) TurnEntity cone,0,1,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 draws the scene, as seen by every camera, to the current ; buffer. Nothing appears on screen until Flip shows the finished frame. RenderWorld Text 0,0,"Arrow keys: move camera Esc: exit" Text 0,20,"RenderWorld draws the 3D scene each frame (see CaptureWorld for tweening)" Flip Wend End
Index