Sign in to follow this  

SlimDX + Direct3D 10 + Direct2D/DirectWrite = ?

This topic is 2529 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!

I'm a relatively new user of SlimDX and DirectX, and I am struggling with a few things, but I'll ask about one thing at a time.

I want to combine a breathtaking 2D user interface into the game engine I am planning to play around with. I have been led to believe(by myself that is) that this is most easily accomplished with Direct2D and DirectWrite in combination with Direct3D.

The rest of my question is basically a follow up if the answer is yes to the following question so you can ignore the rest if it isn't.

Is Direct2D / DirectWrite the way to go to render great text/shapes? Specifically for something like a fluid UI with transparency and fluid animation?

If not, what should I try instead?

If it is a good approach, can someone tell me what my mistake is in the following code? Some things are excluded for brevity, ask me for more if you need!


public void StartEngine()
{
Device = new SlimDX.Direct3D10_1.Device1(Factory.GetAdapter(0), DriverType.Hardware, DeviceCreationFlags.BgraSupport, SlimDX.Direct3D10_1.FeatureLevel.Level_10_0);
...
...
...
RenderTarget = RenderTarget.FromDXGI(D2DFactory, surface, new RenderTargetProperties() { PixelFormat = new PixelFormat(surface.Description.Format, AlphaMode.Straight), Type = RenderTargetType.Hardware, Usage = RenderTargetUsage.None });
}



When I try to create my render target, a Direct2DException is thrown, with the following text:


D2DERR_UNSUPPORTED_PIXEL_FORMAT: The pixel format is not supported. (-2003292288)



Any ideas what I am doing wrong? Also, sorry if this has been asked before but google told me no...

Share this post


Link to post
Share on other sites
Hm, I wanted to edit because I missed a bit of vital code in my example. Seems I can't find the edit button? I see no option but posting again, sorry!


public void StartEngine()
{
Device = new SlimDX.Direct3D10_1.Device1(Factory.GetAdapter(0), DriverType.Hardware, DeviceCreationFlags.BgraSupport, SlimDX.Direct3D10_1.FeatureLevel.Level_10_0);
...
...
...
SwapChain = new SlimDX.DXGI.SwapChain(Factory, Device, new DXGI.SwapChainDescription
{
BufferCount = 1,
Flags = DXGI.SwapChainFlags.AllowModeSwitch,
IsWindowed = true,
ModeDescription = new DXGI.ModeDescription(width, height, new Rational(60, 1), DXGI.Format.R8G8B8A8_UNorm),
OutputHandle = handle,
SampleDescription = new DXGI.SampleDescription(1, 0),
SwapEffect = DXGI.SwapEffect.Discard,
Usage = DXGI.Usage.RenderTargetOutput
});
Surface surface = SlimDX.DXGI.Surface.FromSwapChain(context.SwapChain, 0);
RenderTarget = RenderTarget.FromDXGI(D2DFactory, surface, new RenderTargetProperties() { PixelFormat = new PixelFormat(surface.Description.Format, AlphaMode.Straight), Type = RenderTargetType.Hardware, Usage = RenderTargetUsage.None });
}


Share this post


Link to post
Share on other sites
Hi!

I'm having a similar issue. When I want to create the D2D RenderTarget from my DXGI Surface I got from the swapchain, I get an E_INVALIDARG. I have read the docs and all parameters seem fine.

My main concern is that I don't get debug output properly. I enabled unmanaged code debugging in project settings and enabled the D3D10/11 debug runtime for my app. Despite all this I get a message in the debug ouput stating that the D2D debug layer failed to initialize.

I'm using D3D10.1 with D2D.

Any ideas why the debug output isn't working? (tried while debugging in VS and running in PIX)

Share this post


Link to post
Share on other sites
Problem solved!

I was unaware of the fact that the Direct2D debug layer is not installed by either Visual Studio 2010 (which installs a lot of SDKs and stuff) or the DirectX SDK. It can be downloaded from: [url="http://code.msdn.microsoft.com/Direct2DTools/"]http://code.msdn.mic.../Direct2DTools/[/url]

After installing it, the debug messages appear in the debug output window, and that told me why I received the E_INVALIDARG (forgot to request BGRA support when creating the D3D device).

Share this post


Link to post
Share on other sites

This topic is 2529 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