/// <summary> /// Creates new instance of <see cref="D3D11Image"/> Associates an D3D11 render target with the current instance. /// </summary> /// <param name="device">A valid D3D9 DeviceEx.</param> /// <param name="renderTarget">A valid D3D11 render target. It must be created with the "Shared" flag.</param> public D3D11Image(DeviceEx device, Direct3D11.Texture2D renderTarget) { using (var resource = renderTarget.QueryInterface<DXGI.Resource>()) { var handle = resource.SharedHandle; texture = new Texture(device, renderTarget.Description.Width, renderTarget.Description.Height, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default, ref handle); } using (var surface = texture.GetSurfaceLevel(0)) { textureSurfaceHandle = surface.NativePointer; TrySetBackbufferPointer(textureSurfaceHandle); } this.IsFrontBufferAvailableChanged += HandleIsFrontBufferAvailableChanged; }
/// <summary> /// Associates an D3D11 render target with the current instance. /// </summary> /// <param name="renderTarget">An valid D3D11 render target. It must be created with the "Shared" flag.</param> internal void SetBackbuffer(Direct3D11.Texture2D renderTarget) { DisposedGuard(); DisposeD3D9Backbuffer(); using (var resource = renderTarget.QueryInterface<DXGI.Resource>()) { var handle = resource.SharedHandle; texture = new Texture(device9, renderTarget.Description.Width, renderTarget.Description.Height, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default, ref handle); } using (var surface = texture.GetSurfaceLevel(0)) TrySetBackbufferPointer(surface.NativePointer); }