Rendering the Game

Now you need to update the rendering code that you wrote a few chapters ago to handle rendering both the user interface screens and the game itself. Use the code from Listing 17.7 to replace the current rendering method you have defined.

Listing 17.7. Rendering the Scene
 public void OnFrameRender(Device device, double appTime, float elapsedTime) { bool beginSceneCalled = false; // Clear the render target and the zbuffer device.Clear(ClearFlags.ZBuffer | ClearFlags.Target, 0, 1.0f, 0); try { device.BeginScene(); beginSceneCalled = true; if (isMainMenuShowing) { mainScreen.Draw(this); } else { // Set the white material, it will be used for the // majority of the rendering device.Material = WhiteMaterial; // Render the game's ...

Get Beginning 3D Game Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.