简体   繁体   English

创建本机C ++ OpenGL 3D编辑器并将其用作C#中的WinForms或WPF控件

[英]Creating native C++ OpenGL 3D editor and using it as a WinForms or WPF control in C#

I want to create a simple 3D editor program, and I don't like C++ windows programming. 我想创建一个简单的3D编辑器程序,我不喜欢C ++ windows编程。 But I don't want to mess with managed code when using OpenGL, either. 但是,我也不想在使用OpenGL时弄乱托管代码。 So, it is possible to create in native C++ a control which will host the OpenGL 3D drawing surface, with no other controls, and also with an interface (methods and properties), and use it as a control in a WinForms, or even better, WPF application? 因此,可以在本机C ++中创建一个控件,它将托管OpenGL 3D绘图表面,没有其他控件,也有接口(方法和属性),并将其用作WinForms中的控件,甚至更好,WPF申请?

It is also possible to use managed C++. 也可以使用托管C ++。 I created a simple OpenGL control for WinForms which suits your requirements. 我为WinForms创建了一个简单的OpenGL控件,它符合您的要求。 You can find more info about it here . 你可以在这里找到更多关于它的信息

Does it have to be OpenGL? 它必须是OpenGL吗? Consider using XNA which would let you use C# and DirectX. 考虑使用XNA,它可以让你使用C#和DirectX。 Otherwise I suggest you find a C# wrapper for OpenGL. 否则我建议你找一个OpenGL的C#包装器。 There are two wrappers listed here http://www.opengl.org/resources/bindings/ . 这里列出了两个包装器http://www.opengl.org/resources/bindings/

I dont really understand your intention. 我真的不明白你的意图。 You said that you hate C++ programming, you dont want to mess with managed code when using OpenGL, you want opengl windows with no ui control but you want winform or wpf as you ui. 你说你讨厌C ++编程,你不想在使用OpenGL时弄乱托管代码,你想要没有ui控制的opengl窗口,但是你想要winform或wpf。

If you hate programming c++, you have to use managed code. 如果你讨厌编程c ++,你必须使用托管代码。 If you dont want to mess with managed code when using OpenGL, you have to use c++ programming. 如果您不想在使用OpenGL时弄乱托管代码,则必须使用c ++编程。 if you want to create in native C++ a control which will host the OpenGL 3D drawing surface, with no other controls(which i assume UI controls), why consider winform or wpf? 如果你想在原生C ++中创建一个控件,它将托管OpenGL 3D绘图表面,没有其他控件(我假设UI控件),为什么要考虑winform或wpf?

Dont use WPF to create 3d heavy applications. 不要使用WPF来创建3d繁重的应用程序。 wpf was meant as a ui. wpf意为ui。 you will find a lot of limitation along the way. 你会发现很多限制。 There is also limitation in hosting(WPF), which makes it useless to use opengl with wpf. 托管(WPF)也有局限性,这使得将opengl与wpf一起使用变得毫无用处。

I think the best bet would be XNA or http://www.opentk.com/(if you must use OpenGL). 我认为最好的选择是XNA或http://www.opentk.com/(如果你必须使用OpenGL)。 Tao Framework is obsolete and is not worth the effort. Tao Framework已经过时,不值得付出努力。

I suggest you look at Ogre 3D ( http://www.ogre3d.org ). 我建议你看看Ogre 3D( http://www.ogre3d.org )。 This cross-platform C++ library covers Open GL as well as DirectX. 这个跨平台的C ++库涵盖Open GL和DirectX。 It has been successfully embedded in Qt, MFC and even has .NET representation. 它已经成功嵌入到Qt,MFC中,甚至还有.NET表示。 I highly suggest you take a look at it. 我强烈建议你看看它。

您所要做的就是在c ++中创建一个包装器,在c#中公开函数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM