示例#1
0
 void ResetDevice(GLControlWrapper_SlimDX9 control)
 {
     SuspendRenderTargets();
     FreeControlSwapChain(control);
     for (; ;)
     {
         var result = dev.TestCooperativeLevel();
         if (result.IsSuccess)
         {
             break;
         }
         if (result.Code == D3DERR_DEVICENOTRESET)
         {
             try
             {
                 var pp = MakePresentParameters();
                 dev.Reset(pp);
                 break;
             }
             catch { }
         }
         System.Threading.Thread.Sleep(100);
     }
     RefreshControlSwapChain(control);
     ResumeRenderTargets();
 }
示例#2
0
 public void BeginControl(GLControlWrapper_SlimDX9 control)
 {
     _CurrentControl = control;
     //don't dispose this backbuffer reference, even though it's tempting to.
     //it results in weird flashes of corruption when changing the vsync setting (unproven; it's another similar code sequence that broke it)
     dev.SetRenderTarget(0, _CurrentControl.SwapChain.GetBackBuffer(0));
 }
示例#3
0
        public void RefreshControlSwapChain(GLControlWrapper_SlimDX9 control)
        {
            if (control.SwapChain != null)
            {
                control.SwapChain.Dispose();
                control.SwapChain = null;
            }
            ResetHandlers.Remove(control, "SwapChain");

            var pp = new PresentParameters
            {
                BackBufferWidth      = Math.Max(8, control.ClientSize.Width),
                BackBufferHeight     = Math.Max(8, control.ClientSize.Height),
                BackBufferCount      = 1,
                BackBufferFormat     = Format.X8R8G8B8,
                DeviceWindowHandle   = control.Handle,
                Windowed             = true,
                PresentationInterval = control.Vsync ? PresentInterval.One : PresentInterval.Immediate
            };

            control.SwapChain = new SwapChain(dev, pp);
            ResetHandlers.Add(control, "SwapChain", () =>
            {
                control.SwapChain.Dispose();
                control.SwapChain = null;
            },
                              () => RefreshControlSwapChain(control));
        }
示例#4
0
        public IGraphicsControl Internal_CreateGraphicsControl()
        {
            var ret = new GLControlWrapper_SlimDX9(this);

            RefreshControlSwapChain(ret);
            return(ret);
        }
示例#5
0
        public void BeginControl(GLControlWrapper_SlimDX9 control)
        {
            _CurrentControl = control;
            var bb = control.SwapChain.GetBackBuffer(0);

            dev.SetRenderTarget(0, bb);
            bb.Dispose();
        }
示例#6
0
 public void FreeControlSwapChain(GLControlWrapper_SlimDX9 control)
 {
     if (control.SwapChain != null)
     {
         control.SwapChain.Dispose();
         control.SwapChain = null;
     }
 }
示例#7
0
        public void EndControl(GLControlWrapper_SlimDX9 control)
        {
            if (control != _CurrentControl)
            {
                throw new InvalidOperationException();
            }

            _CurrentControl = null;
        }
示例#8
0
        public void BeginControl(GLControlWrapper_SlimDX9 control)
        {
            _CurrentControl = control;

            //this dispose isnt strictly needed but it seems benign
            var surface = _CurrentControl.SwapChain.GetBackBuffer(0);

            dev.SetRenderTarget(0, surface);
            surface.Dispose();
        }
示例#9
0
        public void EndControl(GLControlWrapper_SlimDX9 control)
        {
            if (control != _CurrentControl)
            {
                throw new InvalidOperationException();
            }

            dev.SetRenderTarget(0, devBB);

            _CurrentControl = null;
        }
示例#10
0
        public void EndControl(GLControlWrapper_SlimDX9 control)
        {
            if (control != _CurrentControl)
            {
                throw new InvalidOperationException();
            }

            //don't dispose this backbuffer reference, even though it's tempting to.
            //it results in weird flashes of corruption when changing the vsync setting (unproven; it's another similar code sequence that broke it)
            dev.SetRenderTarget(0, dev.GetBackBuffer(0, 0));

            _CurrentControl = null;
        }
示例#11
0
        public void EndControl(GLControlWrapper_SlimDX9 control)
        {
            if (control != _CurrentControl)
            {
                throw new InvalidOperationException();
            }

            var surface = _CurrentControl.SwapChain.GetBackBuffer(0);

            dev.SetRenderTarget(0, surface);
            surface.Dispose();

            _CurrentControl = null;
        }
示例#12
0
        public void EndControl(GLControlWrapper_SlimDX9 control)
        {
            if (control != _CurrentControl)
            {
                throw new InvalidOperationException();
            }

            var bb = dev.GetBackBuffer(0, 0);

            dev.SetRenderTarget(0, bb);
            bb.Dispose();

            _CurrentControl = null;
        }
示例#13
0
        public void SwapControl(GLControlWrapper_SlimDX9 control)
        {
            EndControl(control);

            try
            {
                var result = control.SwapChain.Present(Present.None);
            }
            catch (d3d9.Direct3D9Exception ex)
            {
                if (ex.ResultCode.Name == "D3DERR_DEVICELOST")
                {
                    ResetDevice();
                }
            }
        }
示例#14
0
        public void SwapControl(GLControlWrapper_SlimDX9 control)
        {
            EndControl(control);

            try
            {
                var result = control.SwapChain.Present(Present.None);
                //var rs = dev.GetRasterStatus(0);
            }
            catch (d3d9.Direct3D9Exception ex)
            {
                if (ex.ResultCode.Code == D3DERR_DEVICELOST)
                {
                    ResetDevice(control);
                }
            }
        }
示例#15
0
        public void RefreshControlSwapChain(GLControlWrapper_SlimDX9 control)
        {
            FreeControlSwapChain(control);

            var pp = new PresentParameters
            {
                BackBufferWidth      = Math.Max(8, control.ClientSize.Width),
                BackBufferHeight     = Math.Max(8, control.ClientSize.Height),
                BackBufferCount      = 1,
                BackBufferFormat     = Format.X8R8G8B8,
                DeviceWindowHandle   = control.Handle,
                Windowed             = true,
                PresentationInterval = control.Vsync ? PresentInterval.One : PresentInterval.Immediate
            };

            control.SwapChain = new SwapChain(dev, pp);
        }
示例#16
0
 public void BeginControl(GLControlWrapper_SlimDX9 control)
 {
     _CurrentControl = control;
     dev.SetRenderTarget(0, control.SwapChain.GetBackBuffer(0));
 }
示例#17
0
 public void BeginControl(GLControlWrapper_SlimDX9 control)
 {
 }
示例#18
0
 public void EndControl(GLControlWrapper_SlimDX9 control)
 {
 }
示例#19
0
 public void SwapControl(GLControlWrapper_SlimDX9 control)
 {
 }
示例#20
0
		public IGraphicsControl Internal_CreateGraphicsControl()
		{
			var ret = new GLControlWrapper_SlimDX9(this);
			RefreshControlSwapChain(ret);
			return ret;
		}
示例#21
0
		public void EndControl(GLControlWrapper_SlimDX9 control)
		{
			if (control != _CurrentControl)
				throw new InvalidOperationException();

			var bb = dev.GetBackBuffer(0,0);
			dev.SetRenderTarget(0,bb);
			bb.Dispose();

			_CurrentControl = null;
		}
示例#22
0
		public void SwapControl(GLControlWrapper_SlimDX9 control)
		{
			EndControl(control);

			try
			{
				var result = control.SwapChain.Present(Present.None);
			}
			catch(d3d9.Direct3D9Exception ex)
			{
				if (ex.ResultCode.Name == "D3DERR_DEVICELOST")
					ResetDevice();
			}
		}
示例#23
0
		public void SwapControl(GLControlWrapper_SlimDX9 control)
		{
			control.SwapChain.Present(Present.None);
		}
示例#24
0
        public void BeginControl(GLControlWrapper_SlimDX9 control)
        {
            _CurrentControl = control;

            //this dispose isnt strictly needed but it seems benign
            var surface = _CurrentControl.SwapChain.GetBackBuffer(0);
            dev.SetRenderTarget(0, surface);
            surface.Dispose();
        }
示例#25
0
 public void SwapControl(GLControlWrapper_SlimDX9 control)
 {
 }
示例#26
0
		public void EndControl(GLControlWrapper_SlimDX9 control)
		{
			if (control != _CurrentControl)
				throw new InvalidOperationException();

			_CurrentControl = null;
		}
示例#27
0
 public void BeginControl(GLControlWrapper_SlimDX9 control)
 {
 }
示例#28
0
        public void EndControl(GLControlWrapper_SlimDX9 control)
        {
            if (control != _CurrentControl)
                throw new InvalidOperationException();

            dev.SetRenderTarget(0, devBB);

            _CurrentControl = null;
        }
示例#29
0
		public void RefreshControlSwapChain(GLControlWrapper_SlimDX9 control)
		{
			if (control.SwapChain != null)
			{
				control.SwapChain.Dispose();
				control.SwapChain = null;
			}
			ResetHandlers.Remove(control, "SwapChain");
			
			var pp = new PresentParameters
			{
				BackBufferWidth = Math.Max(8,control.ClientSize.Width),
				BackBufferHeight = Math.Max(8, control.ClientSize.Height),
				BackBufferCount = 2,
				BackBufferFormat = Format.X8R8G8B8,
				DeviceWindowHandle = control.Handle,
				Windowed = true,
				PresentationInterval = control.Vsync ? PresentInterval.One : PresentInterval.Immediate
			};

			control.SwapChain = new SwapChain(dev, pp);
			ResetHandlers.Add(control, "SwapChain", () => { control.SwapChain.Dispose(); control.SwapChain = null; }, () => RefreshControlSwapChain(control));
		}
示例#30
0
		public void BeginControl(GLControlWrapper_SlimDX9 control)
		{
			_CurrentControl = control;
			var bb = control.SwapChain.GetBackBuffer(0);
			dev.SetRenderTarget(0, bb);
			bb.Dispose();
		}
示例#31
0
 public void EndControl(GLControlWrapper_SlimDX9 control)
 {
 }
示例#32
0
		public void BeginControl(GLControlWrapper_SlimDX9 control)
		{
			_CurrentControl = control;
			dev.SetRenderTarget(0, control.SwapChain.GetBackBuffer(0));
		}
示例#33
0
 public void SwapControl(GLControlWrapper_SlimDX9 control)
 {
     control.SwapChain.Present(Present.None);
 }