public void Shutdown() { // Release the light object. Light = null; // Release the camera object. Camera = null; // Release the light shader object. LightShader?.ShutDown(); LightShader = null; // Release the deferred shader object. DeferredShader?.ShutDown(); DeferredShader = null; // Release the deferred buffers object. DeferredBuffers?.Shutdown(); DeferredBuffers = null; // Release the full screen ortho window object. FullScreenWindow?.Shutdown(); FullScreenWindow = null; // Release the tree object. Model?.Shutdown(); Model = null; // Release the input object. Input?.Shutdown(); Input = null; // Release the Direct3D object. D3D?.ShutDown(); D3D = null; }
private bool RenderSceneToTexture() { // Set the render buffers to be the render target. DeferredBuffers.SetRenderTargets(D3D.DeviceContext); // Clear the render buffers. DeferredBuffers.ClearRenderTargets(D3D.DeviceContext, 0.0f, 0.0f, 0.0f, 1.0f); // Get the matrices from the camera and d3d objects. Matrix worldMatrix = D3D.WorldMatrix; Matrix cameraViewMatrix = Camera.ViewMatrix; Matrix projectionMatrix = D3D.ProjectionMatrix; // Update the rotation variable each frame. Rotate(); // Rotate the world matrix by the rotation value so that the cube will spin. Matrix.RotationY(Rotation, out worldMatrix); // Put the model vertex and index buffers on the graphics pipeline to prepare them for drawing. Model.Render(D3D.DeviceContext); // Render the model using the deferred shader. if (!DeferredShader.Render(D3D.DeviceContext, Model.IndexCount, worldMatrix, cameraViewMatrix, projectionMatrix, Model.Texture.TextureResource)) { return(false); } // Reset the render target back to the original back buffer and not the render buffers anymore. D3D.SetBackBufferRenderTarget(); // Reset the viewport back to the original. D3D.ResetViewPort(); return(true); }