private void CopyRenderTargetToTexture() { #if false // RJT TODO: If using D3D12 we need to read the current 'Display.main.colorBuffer', pass it down // to native and extract the texture using 'IUnityGraphicsD3D12v5::TextureFromRenderBuffer()' // - Although, as is, this doesn't work: https://forum.unity.com/threads/direct3d12-native-plugin-render-to-screen.733025/ if (_targetNativePointer == System.IntPtr.Zero) { _targetNativePointer = Display.main.colorBuffer.GetNativeRenderBufferPtr(); // _targetNativePointer = Graphics.activeColorBuffer.GetNativeRenderBufferPtr(); NativePlugin.SetColourBuffer(_handle, _targetNativePointer); } #endif #if true if ((_targetNativePointer == System.IntPtr.Zero) || (_resolveTexture && ((_resolveTexture.width != Screen.width) || (_resolveTexture.height != Screen.height))) ) { FreeRenderResources(); // Create RT matching screen extents _resolveTexture = RenderTexture.GetTemporary(Screen.width, Screen.height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB, 1); _resolveTexture.Create(); _targetNativePointer = _resolveTexture.GetNativeTexturePtr(); NativePlugin.SetTexturePointer(_handle, _targetNativePointer); // Create command buffer _commandBuffer = new CommandBuffer(); _commandBuffer.name = "AVPro Movie Capture copy"; _commandBuffer.Blit(BuiltinRenderTextureType.CurrentActive, _resolveTexture); } #endif Graphics.ExecuteCommandBuffer(_commandBuffer); }
public override void UnprepareCapture() { if (_handle != -1) { #if false NativePlugin.SetColourBuffer(_handle, System.IntPtr.Zero); #endif NativePlugin.SetTexturePointer(_handle, System.IntPtr.Zero); } FreeRenderResources(); if (_mouseCursor != null) { _mouseCursor.enabled = false; } base.UnprepareCapture(); }