/// <summary> /// Reset the _renderTarget so that we are sure it will have the correct presentation parameters (required to support working across changes to windowed/fullscreen or resolution changes) /// </summary> /// <param name="devicePtr"></param> /// <param name="presentParameters"></param> /// <returns></returns> int ResetHook(IntPtr devicePtr, ref D3DPRESENT_PARAMETERS presentParameters) { using (Device device = Device.FromPointer(devicePtr)) { PresentParameters pp = new PresentParameters() { AutoDepthStencilFormat = (Format)presentParameters.AutoDepthStencilFormat, BackBufferCount = presentParameters.BackBufferCount, BackBufferFormat = (Format)presentParameters.BackBufferFormat, BackBufferHeight = presentParameters.BackBufferHeight, BackBufferWidth = presentParameters.BackBufferWidth, DeviceWindowHandle = presentParameters.DeviceWindowHandle, EnableAutoDepthStencil = presentParameters.EnableAutoDepthStencil, FullScreenRefreshRateInHertz = presentParameters.FullScreen_RefreshRateInHz, Multisample = (MultisampleType)presentParameters.MultiSampleType, MultisampleQuality = presentParameters.MultiSampleQuality, PresentationInterval = (PresentInterval)presentParameters.PresentationInterval, PresentFlags = (PresentFlags)presentParameters.Flags, SwapEffect = (SwapEffect)presentParameters.SwapEffect, Windowed = presentParameters.Windowed }; lock (_lockRenderTarget) { if (_renderTarget != null) { _renderTarget.Dispose(); _renderTarget = null; } } // EasyHook has already repatched the original Reset so calling it here will not cause an endless recursion to this function return(device.Reset(pp).Code); } }
/// <summary> /// Reset the _renderTarget so that we are sure it will have the correct presentation parameters (required to support working across changes to windowed/fullscreen or resolution changes) /// </summary> /// <param name="devicePtr"></param> /// <param name="presentParameters"></param> /// <returns></returns> int ResetHook(IntPtr devicePtr, ref D3DPRESENT_PARAMETERS presentParameters) { using (Device device = Device.FromPointer(devicePtr)) { PresentParameters pp = new PresentParameters() { AutoDepthStencilFormat = (Format)presentParameters.AutoDepthStencilFormat, BackBufferCount = presentParameters.BackBufferCount, BackBufferFormat = (Format)presentParameters.BackBufferFormat, BackBufferHeight = presentParameters.BackBufferHeight, BackBufferWidth = presentParameters.BackBufferWidth, DeviceWindowHandle = presentParameters.DeviceWindowHandle, EnableAutoDepthStencil = presentParameters.EnableAutoDepthStencil, FullScreenRefreshRateInHertz = presentParameters.FullScreen_RefreshRateInHz, Multisample = (MultisampleType)presentParameters.MultiSampleType, MultisampleQuality = presentParameters.MultiSampleQuality, PresentationInterval = (PresentInterval)presentParameters.PresentationInterval, PresentFlags = SlimDX.Direct3D9.PresentFlags.LockableBackBuffer, //PresentFlags = (PresentFlags)presentParameters.Flags, SwapEffect = (SwapEffect)presentParameters.SwapEffect, Windowed = presentParameters.Windowed //Windowed = true }; lock (_lockRenderTarget) { if (_renderTarget != null) { _renderTarget.Dispose(); _renderTarget = null; } if (renderTargetTemp != null) { renderTargetTemp.Dispose(); renderTargetTemp = null; } } // EasyHook has already repatched the original Reset so calling it here will not cause an endless recursion to this function return device.Reset(pp).Code; } }
/// <summary> /// The IDirect3DDevice9.Reset function definition /// </summary> /// <param name="device"></param> /// <param name="presentParameters"></param> /// <returns></returns> //[UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode, SetLastError = true)] //delegate int Direct3D9Device_ReleaseDelegate(IntPtr device); //int ReleaseHook(IntPtr devicePtr) //{ // try // { // //this.DebugMessage("ResetHook: start"); // using (Device device = Device.FromPointer(devicePtr)) // { // return device. // } // } //} /// <summary> /// Reset the _renderTarget so that we are sure it will have the correct presentation parameters (required to support working across changes to windowed/fullscreen or resolution changes) /// </summary> /// <param name="devicePtr"></param> /// <param name="presentParameters"></param> /// <returns></returns> int ResetHook(IntPtr devicePtr, ref D3DPRESENT_PARAMETERS presentParameters) { try { DebugMessage("ResetHook: start"); using (Device device = Device.FromPointer(devicePtr)) { PresentParameters pp = new PresentParameters() { AutoDepthStencilFormat = (Format)presentParameters.AutoDepthStencilFormat, BackBufferCount = presentParameters.BackBufferCount, BackBufferFormat = (Format)presentParameters.BackBufferFormat, BackBufferHeight = presentParameters.BackBufferHeight, BackBufferWidth = presentParameters.BackBufferWidth, DeviceWindowHandle = presentParameters.DeviceWindowHandle, EnableAutoDepthStencil = presentParameters.EnableAutoDepthStencil, FullScreenRefreshRateInHertz = presentParameters.FullScreen_RefreshRateInHz, Multisample = (MultisampleType)presentParameters.MultiSampleType, MultisampleQuality = presentParameters.MultiSampleQuality, PresentationInterval = (PresentInterval)presentParameters.PresentationInterval, PresentFlags = (PresentFlags)presentParameters.Flags, SwapEffect = (SwapEffect)presentParameters.SwapEffect, Windowed = presentParameters.Windowed }; String s= "AutoDepthStencilFormat = "+pp.AutoDepthStencilFormat.ToString()+ ", BackBufferCount = "+pp.BackBufferCount.ToString()+ ", BackBufferFormat = "+pp.BackBufferFormat.ToString()+ ", BackBufferHeight = " + pp.BackBufferHeight.ToString() + ", BackBufferWidth = " + pp.BackBufferWidth.ToString() + ", DeviceWindowHandle = " + pp.DeviceWindowHandle.ToString() + ", EnableAutoDepthStencil = "+pp.EnableAutoDepthStencil.ToString()+ ", FullScreenRefreshRateInHertz = " + pp.FullScreenRefreshRateInHertz.ToString() + ", Multisample = "+pp.Multisample.ToString()+ ", MultisampleQuality = "+pp.MultisampleQuality.ToString()+ ", PresentationInterval = "+pp.PresentationInterval.ToString()+ ", PresentFlags = "+pp.PresentFlags.ToString()+ ", SwapEffect = " + pp.SwapEffect.ToString() + ", Windowed = "+pp.Windowed.ToString(); //DebugMessage(s); lock (_lockRenderTarget) { Cleanup(); } //this.DebugMessage("ResetHook: end"); // EasyHook has already repatched the original Reset so calling it here will not cause an endless recursion to this function return device.Reset(pp).Code; } } catch (Exception ex) { Cleanup(); DebugMessage(ex.ToString()); return System.Runtime.InteropServices.Marshal.GetHRForException(ex); } }
/// <summary> /// The IDirect3DDevice9.Reset function definition /// </summary> /// <param name="device"></param> /// <param name="presentParameters"></param> /// <returns></returns> //[UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode, SetLastError = true)] //delegate int Direct3D9Device_ReleaseDelegate(IntPtr device); //int ReleaseHook(IntPtr devicePtr) //{ // try // { // //this.DebugMessage("ResetHook: start"); // using (Device device = Device.FromPointer(devicePtr)) // { // return device. // } // } //} /// <summary> /// Reset the _renderTarget so that we are sure it will have the correct presentation parameters (required to support working across changes to windowed/fullscreen or resolution changes) /// </summary> /// <param name="devicePtr"></param> /// <param name="presentParameters"></param> /// <returns></returns> int ResetHook(IntPtr devicePtr, ref D3DPRESENT_PARAMETERS presentParameters) { try { DebugMessage("ResetHook: start"); using (Device device = Device.FromPointer(devicePtr)) { PresentParameters pp = new PresentParameters() { AutoDepthStencilFormat = (Format)presentParameters.AutoDepthStencilFormat, BackBufferCount = presentParameters.BackBufferCount, BackBufferFormat = (Format)presentParameters.BackBufferFormat, BackBufferHeight = presentParameters.BackBufferHeight, BackBufferWidth = presentParameters.BackBufferWidth, DeviceWindowHandle = presentParameters.DeviceWindowHandle, EnableAutoDepthStencil = presentParameters.EnableAutoDepthStencil, FullScreenRefreshRateInHertz = presentParameters.FullScreen_RefreshRateInHz, Multisample = (MultisampleType)presentParameters.MultiSampleType, MultisampleQuality = presentParameters.MultiSampleQuality, PresentationInterval = (PresentInterval)presentParameters.PresentationInterval, PresentFlags = (PresentFlags)presentParameters.Flags, SwapEffect = (SwapEffect)presentParameters.SwapEffect, Windowed = presentParameters.Windowed }; String s = "AutoDepthStencilFormat = " + pp.AutoDepthStencilFormat.ToString() + ", BackBufferCount = " + pp.BackBufferCount.ToString() + ", BackBufferFormat = " + pp.BackBufferFormat.ToString() + ", BackBufferHeight = " + pp.BackBufferHeight.ToString() + ", BackBufferWidth = " + pp.BackBufferWidth.ToString() + ", DeviceWindowHandle = " + pp.DeviceWindowHandle.ToString() + ", EnableAutoDepthStencil = " + pp.EnableAutoDepthStencil.ToString() + ", FullScreenRefreshRateInHertz = " + pp.FullScreenRefreshRateInHertz.ToString() + ", Multisample = " + pp.Multisample.ToString() + ", MultisampleQuality = " + pp.MultisampleQuality.ToString() + ", PresentationInterval = " + pp.PresentationInterval.ToString() + ", PresentFlags = " + pp.PresentFlags.ToString() + ", SwapEffect = " + pp.SwapEffect.ToString() + ", Windowed = " + pp.Windowed.ToString(); //DebugMessage(s); lock (_lockRenderTarget) { Cleanup(); } //this.DebugMessage("ResetHook: end"); // EasyHook has already repatched the original Reset so calling it here will not cause an endless recursion to this function return(device.Reset(pp).Code); } } catch (Exception ex) { Cleanup(); DebugMessage(ex.ToString()); return(System.Runtime.InteropServices.Marshal.GetHRForException(ex)); } }