WPF 控件中的 SlimDX 视口

发布于 2024-08-21 18:16:15 字数 884 浏览 11 评论 0原文

我正在从 WinForms/XNA 过渡到 WPF/SlimDX,因为:

  • a) WPF 的所有优点 WinForms(但是学习曲线=哎哟!)
  • b)我想要多个 连接到面板的 SlimDX 视口。 XNA 有 1 个“游戏”屏幕。
  • c,最后也是最不重要的)DirectX 10 支持

我以前的所有 XNA 代码都是用 C# 编写的。我无法弄清楚如何在较高级别上将其移植到 SlimDX 和 WPF。我疯狂地寻找。我发现的最接近的是:

1)http://www.gamedev。网/社区/论坛/topic.asp?topic_id=507941 许多文章都提到了这个讨论,但它并不完整,我无法弄清楚 XAML,并且在附加所有遗漏的 _slimDXDevice 和 Window1 事件后出现设备错误。

2) http://www.codeproject.com/KB/WPF/D3DImage.aspx 本文假设用户正在移植 C++。我正在移植与 MDX 代码非常接近的 XNA 代码。

如果我能得到一个带有自定义 SlimDX 驱动视口(只是一个蓝色框)的 WPF 表单,我就可以从那里开始。在 XNA 中,我渲染了许多单独的 RenderTargets 并将它们放置在屏幕上,现在我想将它们附加到控件。但首先,只有 1 个蓝色盒子! :D

有什么想法吗?我觉得这要么很简单,要么我缺少一些“千篇一律”的代码。非常感谢!

I am transitioning from WinForms/XNA to WPF/SlimDX because:

  • a) all of the benefits of WPF over
    WinForms (but learning curve = ouch!)
  • b) I would like to have multiple
    SlimDX viewports attached to Panels.
    XNA has 1 "game" screen.
  • c, last and least) DirectX 10 support

All of my previous XNA code is in C#. I am having trouble figuring out how to port this over to SlimDX and WPF on a high level. I have searched like crazy. The closest I have found are:

1) http://www.gamedev.net/community/forums/topic.asp?topic_id=507941
Many articles point to this discussion, however it is incomplete and I can't figure out the XAML, and I get device errors after attaching all of the _slimDXDevice and Window1 events that were left out.

2) http://www.codeproject.com/KB/WPF/D3DImage.aspx
This article assumes the user is porting C++. I am porting XNA code which is very close to MDX code.

If I could get to the point where I have a WPF form with a custom SlimDX driven viewport that was just a blue box, I could go from there. In XNA I rendered many separate RenderTargets and placed them all over the screen, now I want to attach them to controls. But first, just 1 blue box! :D

Any ideas? I feel that this is either simple or that there's some "cookie cutter" code that I'm missing. Greatly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

素年丶 2024-08-28 18:16:15

您现在可以查看示例。它刚刚签入我们的存储库,因此您需要使用 SVN 来获取它(或者等到我们发布 2010 年 2 月版本):

http://code.google.com/p/slimdx/source/detail?r=1356

You can look at the sample now. It's just been checked in to our repository, so you'll need to use SVN to get it (or wait until we ship the Feb 2010 release):

http://code.google.com/p/slimdx/source/detail?r=1356

清引 2024-08-28 18:16:15

D3DImage 是您要使用的类。尽管代码项目教程是C++,但它非常适用于SlimDX和WPF。

您所要做的就是正常运行您的 SlimDX 代码,但不要在您的设备或交换链上运行 Present(...)。在您放置 Present(...) 的位置,执行 D3DImage.SetBackBuffer(...) 并将 SlimDX 表面的 ComPointer 属性发送给它。然后执行 D3DImage.AddDirect(...),现在您已经在 WPF 中合成了 D3D。

另外,请确保您创建了一个 IDirect3DDevice9Ex,否则您的性能在除 XP 之外的任何系统中都会很糟糕!

D3DImage is the class you want to use. Even though the codeproject tutorial is C++, it is very applicable to SlimDX and WPF.

All you have to do with your SlimDX, is run your code normally, but DO NOT run a Present(...) on your device or swap chain. At the point where you would put a Present(...), do a D3DImage.SetBackBuffer(...) and send your SlimDX surface's ComPointer property to it. Then do D3DImage.AddDirect(...) and you now have D3D composited in WPF.

Also, make sure you create a IDirect3DDevice9Ex or else your performance will be terrible in anything but XP!

‘画卷フ 2024-08-28 18:16:15

我最近在摆弄 D3DImage 和 SlimDX,并没有发现让它工作太困难(使用 DirextX9)。我的家用电脑上有一些代码,我稍后会发布,但它与提供的链接中的代码非常相似。

但我始终无法让它与更高版本的 directx 一起工作。 Jeremiah 有一个很好的 关于使用 directx9 设备作为 directx 10/11/d2d 和 D3DImage 之间的链接的博客文章,但我无法让它与 Slimdx 一起工作。我并没有投入太多的精力,因为 directx9 做了我需要它做的事情,而且我有点希望它能在 XP 上工作。

I recently was messing around with D3DImage and SlimDX and didn't find it too difficult to get it working (with DirextX9). I have some code at my home pc that I'll post later, but it's pretty similar to the code in the links provided.

I was never able to get it working with a higher version of directx though. Jeremiah has a nice blog post about using a directx9 device as a link between directx 10/11/d2d and the D3DImage, but I couldn't get it working with Slimdx. I didn't put a whole lot of effort into though as directx9 did what I needed it to do and I kind of wanted it to work on XP.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文