Sign in to follow this  

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

This topic is 2659 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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);

Share this post


Link to post
Share on other sites
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);

Share this post


Link to post
Share on other sites

This topic is 2659 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this