private bool Render()
        {
            // Clear the buffers to begin the scene.
            D3D.BeginScene(0.0f, 0.0f, 0.0f, 1.0f);

            // Generate the view matrix based on the camera's position.
            Camera.Render();

            // Get the world, view, and projection matrices from the camera and d3d objects.
            Matrix translationMatrix;
            Matrix worldMatrix      = D3D.WorldMatrix;
            Matrix viewMatrix       = Camera.ViewMatrix;
            Matrix projectionMatrix = D3D.ProjectionMatrix;

            // Setup the rotation and translation of the first model.
            Matrix.RotationY(Rotation, out worldMatrix);
            Matrix.Translation(-3.5f, 0.0f, 0.0f, out translationMatrix);
            Matrix.Multiply(ref worldMatrix, ref translationMatrix, out worldMatrix);

            // Render the first model using the texture shader.
            CubeModel1.Render(D3D.DeviceContext);
            if (!ShaderManager.RenderTextureShader(D3D.DeviceContext, CubeModel1.IndexCount, worldMatrix, viewMatrix, projectionMatrix, CubeModel1.Texture.TextureResource))
            {
                return(false);
            }

            // Setup the rotation and translation of the second model by resetting the worldMatrix too.
            worldMatrix = D3D.WorldMatrix;
            Matrix.RotationY(Rotation, out worldMatrix);
            Matrix.Translation(0.0f, 0.0f, 0.0f, out translationMatrix);
            Matrix.Multiply(ref worldMatrix, ref translationMatrix, out worldMatrix);

            // Render the second model using the light shader.
            CubeModel2.Render(D3D.DeviceContext);
            if (!ShaderManager.RenderLightShader(D3D.DeviceContext, CubeModel2.IndexCount, worldMatrix, viewMatrix, projectionMatrix, CubeModel2.Texture.TextureResource, Light.Direction, Light.AmbientColor, Light.DiffuseColour, Camera.GetPosition(), Light.SpecularColor, Light.SpecularPower))
            {
                return(false);
            }

            // Setup the rotation and translation of the third model.
            worldMatrix = D3D.WorldMatrix;
            Matrix.RotationY(Rotation, out worldMatrix);
            Matrix.Translation(3.5f, 0.0f, 0.0f, out translationMatrix);
            Matrix.Multiply(ref worldMatrix, ref translationMatrix, out worldMatrix);

            // Render the third model using the bump map shader.
            CubeBumpMapModel3.Render(D3D.DeviceContext);
            if (!ShaderManager.RenderBumpMapShader(D3D.DeviceContext, CubeBumpMapModel3.IndexCount, worldMatrix, viewMatrix, projectionMatrix, CubeBumpMapModel3.ColorTexture.TextureResource, CubeBumpMapModel3.NormalMapTexture.TextureResource, Light.Direction, Light.DiffuseColour))
            {
                return(false);
            }

            // Present the rendered scene to the screen.
            D3D.EndScene();

            return(true);
        }
        public void Shutdown()
        {
            // Release the light object.
            Light = null;
            // Release the camera object.
            Camera = null;

            // Release the Second Cube model object.
            CubeModel2?.Shutdown();
            CubeModel2 = null;
            // Release the Third Cube model object.
            CubeBumpMapModel3?.Shutdown();
            CubeBumpMapModel3 = null;
            // Release the First cube model object.
            CubeModel1?.Shutdown();
            CubeModel1 = null;
            // Release the shader manager object.
            ShaderManager?.ShutDown();
            ShaderManager = null;
            // Release the Direct3D object.
            D3D?.ShutDown();
            D3D = null;
        }