CaptureToWorld
CaptureToWorld WorldIndex
 
Parameters:

    WorldIndex = The Index of the world you want to capture to
Returns: NONE
 

      CaptureToWorld switches PlayBASIC behavior to capture all future gfx commands to the selected World Buffer, rather than draw them immediately.

      All types of GFX drawing can be captured to a world buffer, from single Dots, Lines, Circles, Shapes, Images, Sprites and Text, Right through to even Maps.

      To view the contents of a world, we need to use a camera. Cameras are used to translate the contents of the world into the scene buffer. Once there (in the scene buffer) you can render the scene as normal with any camera.



FACTS:


      * You can control of the Z depth of captured GFX items by using the CaptureDepth command

      * World Buffers are static. Once you capture to a world buffer you can't delete the stored graphics elements.





Mini Tutorial:


      This example first creates a world buffer, then fills this world buffer full of static stars. During the main loop, it grabs a camera full of this data from the world buffer and places it in the scenebuffer. Then calls the camera to render it. This allows us to mix data from different worlds, through different cameras, and maintain the scenes depth.


  
  
; Create WOrld
  CreateWorld 1
  
; Tell PB to Capture ALL folloing GFX commands
; to this world buffer
  CaptureToWorld 1
  
; Plot 1000 Stars into this world buffer
  Stars=1000
  W=GetScreenWidth()
  H=GetScreenHeight()
  
  For lp =0 To Stars
     X=Rnd(w)
     y=Rnd(h)
     c=RndRGB()
     DotC x,y,c
     DotC x+w,y,c
  Next
  
; Create camera
  CreateCamera 1
  
  
; Start of DO/LOOP
  Do
   ; Enable Capture to Scene Buffer
     CaptureToScene
     
   ; Clear the scene buffer
     ClsScene
     
   ; Transfer the data from the World buffer
   ; to the scene buffer
     CameraGrabWorld 1,1
     
   ; Draw Camera #1
     DrawCamera 1
     
   ; Move the camera
     x#=x#+1
     PositionCameraX 1,X#
     If x#=>Then x#=x#-w
     
   ; Display the screen
     Sync
     
   ; Loop back to the DO
  Loop
  




This example would output.

  
  no Text output
  

 
Related Info: CameraGrabWorld | CreateWorld | DeleteWorld | GetFreeWorld | GetWorldStatus :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com