I want to create a simple 3D editor program, and I don't like C++ windows programming. But I don't want to mess with managed code when using OpenGL, either. 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?
-
1Do you need to use OpenGL, as you can create 3D objects in WPF? – Samuel Oct 17 '10 at 15:31
-
I'm with Sam. WPF has built-in 3d capabilities, using DirectX under the hood. Are you sure you need to use OpenGL? – Judah Gabriel Himango Oct 17 '10 at 15:45
-
I saw the WPF 3D capabilities, it's easier to work with, but I just have that feeling that is going to be a lot slower and resource hungry than a native app. Do you think WPF 3D is a scalable solution for a little CAD application? – Tiborg Oct 18 '10 at 15:30
-
Hate is such a strong word. What about "I'd rather avoid it unless absolutely forced to at gun-point" ? – Julien Lebot May 31 '12 at 11:43
5 Answers
It is also possible to use managed C++. I created a simple OpenGL control for WinForms which suits your requirements. You can find more info about it here.

- 769
- 8
- 25
Does it have to be OpenGL? Consider using XNA which would let you use C# and DirectX. Otherwise I suggest you find a C# wrapper for OpenGL. There are two wrappers listed here http://www.opengl.org/resources/bindings/.

- 11,092
- 3
- 50
- 63
-
I personally prefer OpenGL because I suck at, and I hate DirectX, and also I think XNA is a framework only for games. I wouldn't mind using an OpenGL wrapper for C# (I've used OpenTK, and it's cool), but I'm especially interested in performance, so I considered using native code instead of managed. If you can provide some links from which I can tell if it's worth the effort of using native C++ instead of managed C#, from a performance point of view, I would be very grateful. Thanks – Tiborg Oct 18 '10 at 07:30
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.
If you hate programming c++, you have to use managed code. If you dont want to mess with managed code when using OpenGL, you have to use c++ programming. 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?
Dont use WPF to create 3d heavy applications. wpf was meant as a 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.
I think the best bet would be XNA or http://www.opentk.com/(if you must use OpenGL). Tao Framework is obsolete and is not worth the effort.

- 4,196
- 11
- 51
- 71
-
I don't hate C++ programming, I hate only C++ WINDOWS programming. To be more explicit, I prefer programming in C++ only the OpenGL part, but I hate programming in C++ the UI. So that was my problem. Also, as I said before, XNA is not suitable for my app because XNA is meant to be used only for managed games. So my initial question (and the most suitable) was if I can use a C++ written OpenGL control (the viewport) for a WinForms app. If this is not possible, I have 2 options: program the whole app in C++ (probably using MFC), or using OpenTK in a managed app. Which do you think is best? – Tiborg Oct 19 '10 at 11:05
-
1If you absolutely need the latest and greatest, consider using native c++ and glut like framework(maybe glfw). if you need to have user interface (i think you do considering you are building 3d editor) and don't mind not having the latest and greatest opengl spec, consider winforms and opentk. just make sure the libraries that you need (im definitely sure you will need to use other support library) is available on the development platform that you chose. – Syaiful Nizam Yahya Oct 20 '10 at 02:58
-
1For me QT is the most painless way to create UI for c++. But i never made any UI in c# so I cant compare.. – Emile Vrijdags Nov 18 '10 at 18:29
I suggest you look at Ogre 3D ( http://www.ogre3d.org ). This cross-platform C++ library covers Open GL as well as DirectX. It has been successfully embedded in Qt, MFC and even has .NET representation. I highly suggest you take a look at it.

- 38,257
- 10
- 78
- 128
All you have to do is create a wrapper in c++ that exposes functions in c#

- 1,448
- 13
- 18