Axiom.RenderSystems.DirectX9.D3DRenderWindow.Update C# (CSharp) Method

Update() public method

public Update ( bool swapBuffers ) : void
swapBuffers bool
return void
		public override void Update( bool swapBuffers )
		{
			D3DRenderSystem rs = (D3DRenderSystem)Root.Instance.RenderSystem;

			// access device through driver
			var device = D3DDevice;



            if (D3DRenderSystem.DeviceManager.ActiveDevice.IsDeviceLost)
			{
				DX.Result result = device.TestCooperativeLevel();
				if ( result.Code == D3D.ResultCode.DeviceLost.Code  )
				{
					// device lost, and we can't reset
					// can't do anything about it here, wait until we get
					// D3DERR_DEVICENOTRESET; rendering calls will silently fail until
					// then (except Present, but we ignore device lost there too)
                    /*
					_renderSurface.ReleaseDC( _renderSurface.GetDC() );
					// need to release if swap chain
					if ( !_isSwapChain )
					{
						_renderZBuffer = null;
					}
					else
					{
						_renderZBuffer.ReleaseDC( _renderZBuffer.GetDC() );
					}*/
					System.Threading.Thread.Sleep( 50 );
					return;
				}
				else if ( result.Code == D3D.ResultCode.DeviceNotReset.Code )
				{
					// device lost, and we can reset
					rs.RestoreLostDevice();

					// Still lost?
                    if (D3DRenderSystem.DeviceManager.ActiveDevice.IsDeviceLost)
					{
						// Wait a while
						System.Threading.Thread.Sleep( 50 );
						return;
					}

					if ( !_isSwapChain )
					{
						// re-qeuery buffers
                        /*
						_renderSurface = device.GetRenderTarget( 0 );
						_renderZBuffer = device.DepthStencilSurface;
                         */
						// release immediately so we don't hog them
						//_renderZBuffer.ReleaseDC( _renderZBuffer.GetDC() );
					}
					else
					{
						// Update dimensions incase changed
						foreach ( Viewport entry in this.ViewportList.Values )
						{
							entry.UpdateDimensions();
						}
					}
				}
				else if ( result.Code != D3D.ResultCode.Success.Code )
					return;
			}

			base.Update( swapBuffers );
		}