First declare the camera: cfirstpersoncamera g_camera; // camera
Then, set the projection matrix in the device initialization function:
// Create and set the Projection Matrix
Float faspectratio = pbackbuffersurfacedesc-> width/(float) pbackbuffersurfacedesc-> height;
G_camera.setprojparams (d3dx_pi/4, faspectratio, 0.1f, 00000000f );
Pd3ddevice-> settransform (d3dts_projection, g_camera.getprojmatrix ());
Then, set the observation matrix in the action of each frame:
G_camera.framemove (felapsedtime); // update the camera Information
Pd3ddevice-> settransform (d3dts_view, g_camera.getviewmatrix (); // sets the observation matrix
Then add the camera's message response to the message response function:
// Add it to the msgproc Function
G_camera.handlemessages (hwnd, umsg, wparam, lparam );
This is OK and I hope it will help you.
Note that g_pd3ddevice-> present (null, null) already exists in cfirstpersoncamera. This operation submits the background information to the foreground, you must stop writing this when writing your own rendering function. Otherwise, the model will flash.