Sign in to follow this  
DrDoktor

Artifacts when using Direct2d to render on Direct3d backbuffer

Recommended Posts

Hi All,

I have a strange problem. Im mixing Direct3d 10 and Direct2d using SlimDX. When I try to draw to the Direct3d backbuffer using Direct2d, I get artifacts when using the FillEllipse() and DrawEllipse() methods. It looks like the triangulation of the primitives is messed up or something like that. Other methods like FillRectangle() is fine. Ive attached a screenshot showing the result.

When drawing Direct2d to a texture and then draw that texture to the backbuffer using regular Direct3d stuff works fine.

The Direct3d10 device is created with Bgra support
Direct2d part of the renderloop looks like this; (snippet)

...

using (var backBuffer = SlimDX.Direct3D10.Resource.FromSwapChain<SlimDX.Direct3D10.Texture2D>(swapChain, 0))
{
SlimDX.DXGI.Surface d2dSurf = backBuffer.AsSurface();
System.Drawing.SizeF dpi = dx10c.D2DFactory.DesktopDpi;
SlimDX.Direct2D.RenderTarget d2dRt = SlimDX.Direct2D.RenderTarget.FromDXGI(dx10c.D2DFactory, d2dSurf,
new SlimDX.Direct2D.RenderTargetProperties()
{
Usage = SlimDX.Direct2D.RenderTargetUsage.None,
Type = SlimDX.Direct2D.RenderTargetType.Default,
PixelFormat = new SlimDX.Direct2D.PixelFormat(SlimDX.DXGI.Format.Unknown, SlimDX.Direct2D.AlphaMode.Premultiplied),
//HorizontalDpi = dpi.Width,
//VerticalDpi = dpi.Height,
});

d2dRt.BeginDraw();

SlimDX.Color4 color = new SlimDX.Color4(System.Drawing.Color.Black);

SlimDX.Direct2D.SolidColorBrush brush = new SlimDX.Direct2D.SolidColorBrush(d2dRt, color);

d2dRt.FillRectangle(brush, new Rectangle()
{
Height = 100,
Width = 100,
Location = new Point(200, 100),
});

d2dRt.FillEllipse(brush, new SlimDX.Direct2D.Ellipse()
{
Center = new Point(400, 100),
RadiusX = 100,
RadiusY = 100,
});
brush.Dispose();



d2dRt.EndDraw();
d2dRt.Dispose();
d2dSurf.Dispose();


....


}






Anyone else experienced the same problem or know what I do wrong?

Many thanks

Share this post


Link to post
Share on other sites

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