For interactive graphics, where views are drawn repeatedly over time, it is often the case that one small part of the view is changing continuously, but the other objects in the view remain static. In such a case, it may be more efficient to take a snapshot of the unchanged portion of the view and display the snapshot for each draw instead of re-rendering each of the unchanging objects from scratch. The objects that are changing are rendered as usual. This process is called instancing. It is to your advantage to use instancing only in cases where displaying the snapshot image is faster than rendering each of the objects that remain unchanged.
The following example shows how a typical instancing loop would be set up. First, hide the objects in the view that will be changing. In this example, we assume that the objects that change continuously are contained by a single model object, with the object reference myChangingModel. We set the HIDE property for this model to remove it from the rendered view.
myChangingModel->SetProperty, HIDE=1 ;Next, create an instance of the remaining portion ;of the view by setting the CREATE_INSTANCE keyword to ;the window's Draw method: myWindow->Draw, myScene, /CREATE_INSTANCE ;Next, hide the unchanging objects. ;Assume that the unchanging portion of the ;scene is contained in a single model object. myUnchangingModel->SetProperty, HIDE=1 ;Set the HIDE property for the changing model ;object equal to zero, revealing the object: myChangingModel->SetProperty, HIDE=0 ;Set the view object's TRANSPARENT property. ;This ensures that we will not erase the ;instance data (the unchanging part of the scene) ;when drawing the changing model. myView->SetProperty, /TRANSPARENT ;Next, we set up a drawing loop that will render ;the changing model. For example, this loop might ;rotate the changing model in 1 degree increments. ROT = 0 FOR i=0,359 DO BEGIN ROT=ROT+1 myChangingModel->Rotate, [0,1,0], ROT myWindow->Draw, myView, /DRAW_INSTANCE ENDFOR ;After the drawing loop is done, ensure nothing is hidden, ;and that the view erases as it did before: myUnchangingModel->SetProperty, HIDE=0 myView->SetProperty, TRANSPARENT=0