DriverGame/DriverGame/DriverGame.cs
/// <summary>
/// When the device is loaded for the first time or when it resets come here to check 
/// the caps of the device for lighting and set up the Projection and view.
/// </summary>
/// <param name="sender">Device</param>
/// <param name="e">usally null, either way we dont care about it.</param>
When the device is loaded for the first time or when it resets come here to check
the caps of the device for lighting and set up the Projection and view.
When the device is loaded for the first time or when it resets come here to check the caps of the device for lighting and set up the Projection and view .
private void OnDeviceReset(object sender, EventArgs e)
        {
            device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, (float)this.Width / (float)this.Height, 1.0f, 1000.0f);
            device.Transform.View = Matrix.LookAtLH(new Vector3(0.0f, 9.5f, 17.0f), new Vector3(), new Vector3(0, 1, 0));
            if (device.DeviceCaps.TextureFilterCaps.SupportsMinifyAnisotropic)
                device.SamplerState[0].MinFilter = TextureFilter.Anisotropic;
            else if (device.DeviceCaps.TextureFilterCaps.SupportsMinifyLinear)
                device.SamplerState[0].MinFilter = TextureFilter.Linear;
            if (device.DeviceCaps.TextureFilterCaps.SupportsMagnifyAnisotropic)
                device.SamplerState[0].MagFilter = TextureFilter.Anisotropic;
            else if (device.DeviceCaps.TextureFilterCaps.SupportsMagnifyLinear)
                device.SamplerState[0].MagFilter = TextureFilter.Linear;
            if ((device.DeviceCaps.VertexProcessingCaps.SupportsDirectionalLights) && (device.DeviceCaps.MaxActiveLights > 1))
            {
                device.Lights[0].Type = LightType.Directional;
                device.Lights[0].Diffuse = Color.White;
                device.Lights[0].Direction = new Vector3(1, -1, -1);
                device.Lights[0].Enabled = true;
                device.Lights[1].Type = LightType.Directional;
                device.Lights[1].Diffuse = Color.White;
                device.Lights[1].Direction = new Vector3(-1, 1, -1);
                device.Lights[1].Enabled = true;
            }
            else
            {
                device.RenderState.Ambient = Color.White;
            }
            roadMesh = LoadMesh(device, @"..\..\road.x", ref roadMaterials, ref roadTextures);
            car = new Car(device);
            obstacles = new Obstacles();
        }
private void OnDeviceReset ( object sender , EventArgs e ) { device . Transform . Projection = Matrix . PerspectiveFovLH ( ( float ) Math . PI / 4 , ( float ) this . Width / ( float ) this . Height , 1.0f , 1000.0f ) ; device . Transform . View = Matrix . LookAtLH ( new Vector3 ( 0.0f , 9.5f , 17.0f ) , new Vector3 ( ) , new Vector3 ( 0 , 1 , 0 ) ) ; if ( device . DeviceCaps . TextureFilterCaps . SupportsMinifyAnisotropic ) device . SamplerState [ 0 ] . MinFilter = TextureFilter . Anisotropic ; else if ( device . DeviceCaps . TextureFilterCaps . SupportsMinifyLinear ) device . SamplerState [ 0 ] . MinFilter = TextureFilter . Linear ; if ( device . DeviceCaps . TextureFilterCaps . SupportsMagnifyAnisotropic ) device . SamplerState [ 0 ] . MagFilter = TextureFilter . Anisotropic ; else if ( device . DeviceCaps . TextureFilterCaps . SupportsMagnifyLinear ) device . SamplerState [ 0 ] . MagFilter = TextureFilter . Linear ; if ( ( device . DeviceCaps . VertexProcessingCaps . SupportsDirectionalLights ) && ( device . DeviceCaps . MaxActiveLights > 1 ) ) { device . Lights [ 0 ] . Type = LightType . Directional ; device . Lights [ 0 ] . Diffuse = Color . White ; device . Lights [ 0 ] . Direction = new Vector3 ( 1 , - 1 , - 1 ) ; device . Lights [ 0 ] . Enabled = true ; device . Lights [ 1 ] . Type = LightType . Directional ; device . Lights [ 1 ] . Diffuse = Color . White ; device . Lights [ 1 ] . Direction = new Vector3 ( - 1 , 1 , - 1 ) ; device . Lights [ 1 ] . Enabled = true ; } else { device . RenderState . Ambient = Color . White ; } roadMesh = LoadMesh ( device , @"..\..\road.x" , ref roadMaterials , ref roadTextures ) ; car = new Car ( device ) ; obstacles = new Obstacles ( ) ; }
When the device is loaded for the first time or when it resets come here to check
the caps of the device for lighting and set up the Projection and view.
When the device is loaded for the first time or when it resets come here to check the caps of the device for lighting and set up the Projection and view .
//try to set up a texture minify filter, pick anisotropic first //do the same thing for magnify filter //Do we have enough support for lights? //first light //second light //no light support, just use ambient lighting. //create teh car //create the obstacles
sender
object
None
e
EventArgs
usally null, either way we dont care about it.
usally null either way we dont care about it .