/// <summary> /// Assigns a <see cref="D3D10.Texture2D"/> as the source of the back buffer. /// </summary> /// <param name="texture"> /// The <c>Texture2D</c> to assign as the back buffer. Value can be null. /// </param> /// <exception cref="InvalidOperationException"> /// The D3D10Image has not been locked by a call to the /// <see cref="D3DImage.Lock" /> or <see cref="D3DImage.TryLock" /> methods. /// </exception> public void SetBackBuffer(D3D10.Texture2D texture) { // Free the old surface if (this.surface != null) { this.surface.Dispose(); this.surface = null; } if (texture == null) { this.SetBackBuffer(D3DResourceType.IDirect3DSurface9, IntPtr.Zero); } else { using (var device = CreateDevice(Interop.NativeMethods.GetDesktopWindow())) using (var texture9 = GetSharedSurface(device, texture)) { this.surface = texture9.GetSurfaceLevel(0); } this.SetBackBuffer(D3DResourceType.IDirect3DSurface9, this.surface.NativeInterface); } }