Beispiel #1
0
        private bool Render(float rotation)
        {
            // Clear the buffer to begin the scene.
            D3D.BeginScene(0f, 0f, 0f, 1f);

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

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

            // Rotate the world matrix by the rotation value so that the triangle 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 color shader.
            if (!LightShader.Render(D3D.DeviceContext, Model.IndexCount, worldMatrix, viewMatrix, projectionMatrix, Model.Texture.TextureResource, Light.Direction, Light.AmbientColor, Light.DiffuseColor))
            {
                return(false);
            }

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

            return(true);
        }