3D in WinForms?

How can I use 3D viewing inside WinForms?

Should I use XNA?

I found this tutorial: http://create.msdn.com/en-US/education/catalog/sample/winforms_series_1

But I don’t understand how to add only ContentLibrary and Content to the WinForms project.

Or is it possible to use Scaleform GFx? for Half2D or 3D?

+6
source share
4 answers

Use WPF. You can mix and match shapes. WPF has a winforms container that you can look into the window and fill it. But you can use WPF out of the box perfectly with a little education - tip = make a fixed window size or resize, there will be hoses of your controls. The exercise of this right is difficult.

Then place the wpf panel for the image where you want 3d. Cut and paste 3d wpf code from the internet.

+5
source

You cannot reference an XNA content project directly from a standard Visual C # project (for example, you might have a default WinForms template).

What you need to do is create an XNA project “Windows Game Library” (even empty), and then use the “Add Content Link” link in this project to add a link to your XNA content project. (The template for this is called the "Empty Content Project".) Then add the link to this new game library project to the WinForms project.

Alternatively, there is nothing that would prevent you from creating a “Windows Game” project and then using “Add Form”, which will add a blank form and the necessary assembly links. You need to change the XNA Game1.cs and Program.cs templates to Program.cs from the standard WinForms project (or see what the WinForms 1 sample uses).

To download dynamic content, check out the WinForms 2 sample.

+9
source

I would recommend using the OpenTK GL control - OpenTK WinForms control . It is cross-platform, easy to use and based on OpenGL; which is cross-platform and mono-compatible. This does not require hacks, and this is a very simple way to embed 3D content in a WinForms container. OpenTK is licensed under LGPL, that is, you can embed it in commercial applications. OpenTK / OpenGL currently runs on Linux, Mac, and Windows, and this is the easiest way I know to embed 3D content in a .NET or Mono application. I tried XNA in the WinForms method, and it turned out to be somewhat confusing, and not cross-platform at all. Then they released XNA 4, and my previous XNA applications were NOT ALL compatible with the new version. You will not find this problem as often in OpenGL as in DirectX.

+7
source

There are several libraries that you can use. IDWMaster mentioned OpenTK, which is one option (OpenGL, so your mileage may vary, I'm not a big fan).

If you want to use DirectX, as you noted the question, there are several more options. Microsoft was offering "DirectX Managed," which is deprecated in favor of XNA. SlimDX is a more modern shell for DirectX libraries, displaying most of their functionality (but it has some performance). SharpDX , which I suppose should be slightly faster than SlimDX, but I haven't used it.

You can also use some of the DirectX API directly using COM interoperability. C # and .Net support pretty good interactions with COM components, including native ones. You will have to handle a significant amount of IntPtr and you may have to do manual marshaling, but IDirect3DDevice does not have too many methods that can cause problems (IIRC).

+1
source

Source: https://habr.com/ru/post/893003/


All Articles