/// <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> private int ResetHook(IntPtr devicePtr, ref PresentParameters presentParameters) { var hresult = Result.Ok.Code; var device = (Device)devicePtr; try { if (!_hooksStarted) { hresult = Direct3DDevice_ResetHook.Original(devicePtr, ref presentParameters); return(hresult); } ClearData(); hresult = Direct3DDevice_ResetHook.Original(devicePtr, ref presentParameters); if (_currentDevice != devicePtr) { _hooksStarted = false; _currentDevice = devicePtr; } } catch (Exception ex) { DebugMessage(ex.ToString()); } return(hresult); }
private unsafe int PresentHook( IntPtr devicePtr, Rectangle *pSourceRect, Rectangle *pDestRect, IntPtr hDestWindowOverride, IntPtr pDirtyRegion) { int hresult; var device = (Device)devicePtr; if (!_hooksStarted) { hresult = Direct3DDevice_PresentHook.Original(devicePtr, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion); return(hresult); } try { if (_presentHookRecurse == 0) { DoCaptureRenderTarget(device, "PresentHook"); } } catch (Exception ex) { DebugMessage(ex.ToString()); } finally { _presentHookRecurse++; hresult = Direct3DDevice_PresentHook.Original(devicePtr, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion); _presentHookRecurse--; } return(hresult); }
// private bool IsDeviceReady(Device device) // { // var cooplevel = device.TestCooperativeLevel(); // if (cooplevel.Code != ResultCode.Success.Code) // { // return false; // } // return true; // } private int ResetExHook(IntPtr devicePtr, ref PresentParameters presentparameters, DisplayModeEx displayModeEx) { int hresult = Result.Ok.Code; DeviceEx device = (DeviceEx)devicePtr; try { if (!hooksStarted) { hresult = Direct3DDeviceEx_ResetExHook.Original(devicePtr, ref presentparameters, displayModeEx); return(hresult); } ClearData(); hresult = Direct3DDeviceEx_ResetExHook.Original(devicePtr, ref presentparameters, displayModeEx); if (currentDevice != devicePtr) { hooksStarted = false; currentDevice = devicePtr; } } catch (Exception ex) { DebugMessage(ex.ToString()); } return(hresult); }
/// <summary> /// Hook for IDirect3DDevice9.EndScene /// </summary> /// <param name="devicePtr">Pointer to the IDirect3DDevice9 instance. Note: object member functions always pass "this" as the first parameter.</param> /// <returns>The HRESULT of the original EndScene</returns> /// <remarks>Remember that this is called many times a second by the Direct3D application - be mindful of memory and performance!</remarks> private int EndSceneHook(IntPtr devicePtr) { int hresult = Result.Ok.Code; var device = (Device)devicePtr; try { if (endSceneHookRecurse == 0) { if (!hooksStarted) { DebugMessage("EndSceneHook: hooks not started"); SetupData(device); } } } catch (Exception ex) { DebugMessage(ex.ToString()); } endSceneHookRecurse++; hresult = Direct3DDevice_EndSceneHook.Original(devicePtr); endSceneHookRecurse--; return(hresult); }
private unsafe int PresentExHook( IntPtr devicePtr, Rectangle *pSourceRect, Rectangle *pDestRect, IntPtr hDestWindowOverride, IntPtr pDirtyRegion, Present dwFlags) { int hresult = Result.Ok.Code; var device = (DeviceEx)devicePtr; if (!hooksStarted) { hresult = Direct3DDeviceEx_PresentExHook.Original(devicePtr, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags); return(hresult); } try { if (this.presentHookRecurse == 0) { this.DoCaptureRenderTarget(device, "PresentEx"); } } catch (Exception ex) { DebugMessage(ex.ToString()); } finally { this.presentHookRecurse++; hresult = Direct3DDeviceEx_PresentExHook.Original(devicePtr, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, dwFlags); this.presentHookRecurse--; } return(hresult); }
/// <summary> /// Hook for IDirect3DDevice9.EndScene /// </summary> /// <param name="devicePtr"> /// Pointer to the IDirect3DDevice9 instance. Note: object member functions always pass "this" as /// the first parameter. /// </param> /// <returns>The HRESULT of the original EndScene</returns> /// <remarks> /// Remember that this is called many times a second by the Direct3D application - be mindful of memory and /// performance! /// </remarks> private int EndSceneHook(IntPtr devicePtr) { var hresult = Result.Ok.Code; var device = (Device)devicePtr; try { if (!_hooksStarted) { DebugMessage("EndSceneHook: hooks not started"); SetupData(device); } } catch (Exception ex) { DebugMessage(ex.ToString()); } hresult = _direct3DDeviceEndSceneHook.Original(devicePtr); return(hresult); }