I think you're on the right track. Don't worry about "interrupt the rendering". There is a lot of processing going on between render calls in any graphics application. How about something like this:
// Have this somewhere appropriate in the code
bool topView = false;
if (KEYDOWN(buffer, DIK_SPACE))
{
// Toggle top view
topView = !topView;
// Set camera vector
if (topView) {
vCamera.y = 90.f;
} else {
vCamera.y = 0.f:
}
}
After updating, you need to send your matrices to DirectX again. Basically you need to call the following chunk of code again now that the vCamera
(or any of the other view vectors) have been changed. I'd suggest bundling the code up in the SetupCamera()
function and call it in the Render()
function, after checking for user input. That would also require to move vCamera
etc out outside the function so that other functions can use them.
// vCamera, vLookat, vUpVector defined outside function
// Call this in rendering loop to set up camera
void SetupCamera() {
// Calculate new view matrix from view vectors
D3DXMATRIX matView;
D3DXMatrixLookAtLH( &matView, &vCamera, &vLookat, &vUpVector);
D3D_Device -> SetTransform(D3DTS_VIEW, &matView);
// Setup Projection Matrix to transform 2D geometry into 3D space
D3DXMATRIX matProj;
D3DXMatrixPerspectiveFovLH(&matProj, D3DX_PI/4, 1.0f, 1.0f, 100.0f);
D3D_Device -> SetTransform(D3DTS_PROJECTION, &matProj);
}