The Rendering Loop

The WinMain function calls the RenderLoop function to draw each new frame of the animation. The RenderLoop function performs a few simple tasks:

·Calls the IDirect3DRMFrame::Move method to apply the rotations and velocities for all frames in the hierarchy.

·Calls the IDirect3DRMViewport::Clear method to clear the current viewport, setting it to the current background color.

·Calls the IDirect3DRMViewport::Render method to render the current scene into the current viewport.

·Calls the IDirect3DRMDevice::Update method to copy the rendered image to the display.

/////////////////////////////////////////////////////////////////////

//

// RenderLoop

// Clear the viewport, render the next frame, and update the window.

//

/////////////////////////////////////////////////////////////////////

static BOOL

RenderLoop()

{

HRESULT rval;

// Tick the scene.

rval = myglobs.scene->lpVtbl->Move(myglobs.scene, D3DVAL(1.0));

if (rval != D3DRM_OK) {

return FALSE;

}

// Clear the viewport.

rval = myglobs.view->lpVtbl->Clear(myglobs.view);

if (rval != D3DRM_OK) {

return FALSE;

}

// Render the scene to the viewport.

rval = myglobs.view->lpVtbl->Render(myglobs.view, myglobs.scene);

if (rval != D3DRM_OK) {

return FALSE;

}

// Update the window.

rval = myglobs.dev->lpVtbl->Update(myglobs.dev);

if (rval != D3DRM_OK) {

return FALSE;

}

return TRUE;

}