[SlimDX] - June 2010 - Direct2D.RenderTarget.FromDXGI fails

Started by
1 comment, last by derby 13 years, 7 months ago
Hi there,
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);
Advertisement
You need to create a D3D10.1 device with the DeviceCreationFlags.BgraSupport flag set in order to interact with D2D. For example:

SlimDX.Direct3D10_1.Device1 device;SwapChain swapChain;SlimDX.Direct3D10_1.Device1.CreateWithSwapChain(null, DriverType.Hardware, DeviceCreationFlags.BgraSupport,   SlimDX.Direct3D10_1.FeatureLevel.Level_10_0, desc, out device, out swapChain);
Mike Popoloski | Journal | SlimDX
Great! Thanks.

This works.

This topic is closed to new replies.

Advertisement