How to use XNA in WPF?

こ雲淡風輕ζ 提交于 2019-12-08 17:21:03

问题


So... I want to make a game, and I want to write it in C#. In the past, I've made a mario clone using C++ and OpenGL. I quite like OpenGL, but I don't know how well it's supported inside C#/WPF. Also, it might be beneficial to use an actual game library? I guess XNA is the game library for C#, so maybe I'll invest a bit of time learning that.

However, I want to use WPF form controls for my level editor... is there any way that I can embed an XNA (DirectX?) window inside a WPF app?

Specifically, I don't need any buttons or things inside the XNA/DirectX widget, just around it, so no mixing required...just need to get a graphics widget in my WPF form.


回答1:


Nick Gravelyn explains how to do it on his blog.

Although, if it's just for an editor, you may find using WinForms is easier and better supported.




回答2:


WPF uses DirectX, and you can do direct "interop" here is a codeProject article on the subject. Here is an article i dug up where the author is using win-forms and WPF controls in an XNA project. Might be worth a look for you.




回答3:


First of all, you should ask this on gamedev.stackexchange.com. But I've seen a tutorial embedding XNA.

You should check this question and this page. They are on Windows Forms, but they'll help.

Also check this and this articles.

Keep in mind one thing. XNA is meant to be used for the whole game, integration would be useful on making level editors like you say, but not for a full game.



来源:https://stackoverflow.com/questions/4121264/how-to-use-xna-in-wpf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!