Animating the Scene

The animation in this sample is simply a rotation about the y-axis. All we need to do is build a rotation matrix and set the world matrix to that new rotation matrix.

We don't need to modify the execute buffer in any way to perform this rotation. We simply set the matrix and resubmit the execute buffer.

static HRESULT

AnimateScene(void)

{

HRESULT hRes;

ASSERT(NULL != lpd3dDevice);

ASSERT(0 != hd3dWorldMatrix);

// We rotate the triangle by setting the world transform to a

// rotation matrix.

SetRotationAboutY(&d3dWorldMatrix, dAngleOfRotation);

dAngleOfRotation += ROTATE_ANGLE_DELTA;

hRes = lpd3dDevice->lpVtbl->SetMatrix(lpd3dDevice,

hd3dWorldMatrix, &d3dWorldMatrix);

if (FAILED(hRes))

return hRes;

return DD_OK;

}