I am trying to get the DXGI RenderTarget working with Direct2D but I am getting the following exception when creating rendertarget with SWAP chain. I am using SlimDX JUNE 2010 release.
"E_INVALIDARG: An invalid parameter was passed to the returning function (-2147024809)"
Any help appreciated.
Here is the sample code.
var desc = new SwapChainDescription() { BufferCount = 1, ModeDescription = new ModeDescription(this.ClientSize.Width, this.ClientSize.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm), IsWindowed = true, OutputHandle = this.Handle, SampleDescription = new SampleDescription(1, 0), SwapEffect = SwapEffect.Discard, Usage = Usage.RenderTargetOutput }; SlimDX.Direct3D10.Device device; SwapChain swapChain; SlimDX.Direct3D10.Device.CreateWithSwapChain(null, SlimDX.Direct3D10.DriverType.Hardware, SlimDX.Direct3D10.DeviceCreationFlags.Debug, desc, out device, out swapChain); SlimDX.DXGI.Surface surface = Surface.FromSwapChain(swapChain, 0); RenderTargetProperties rp = new RenderTargetProperties() { HorizontalDpi = 96, VerticalDpi = 96, MinimumFeatureLevel = FeatureLevel.Default, PixelFormat = new PixelFormat() {AlphaMode = AlphaMode.Premultiplied, Format = SlimDX.DXGI.Format.Unknown}, Type = RenderTargetType.Default, Usage = RenderTargetUsage.None }; //The following line works. SlimDX.Direct3D10.Texture2D backBuffer = SlimDX.Direct3D10.Texture2D.FromSwapChain<SlimDX.Direct3D10.Texture2D>(swapChain, 0); SlimDX.Direct2D.Factory factory = new Factory(FactoryType.SingleThreaded, DebugLevel.Information); //This following line fails. RenderTarget target = RenderTarget.FromDXGI(factory, surface, rp);