0

Is it possible to render VC++ OpenGL output to a panel in Winforms window created with C# ? I'm aware of Tao framework and OpenTK but I don't want to rely on third party support. There is an article here but this is merely only pixel reproduction and I think this method does not guarantee user interaction with OpenGL scene.

Dinesh
  • 13
  • 6

1 Answers1

1

Yes, this is absolutely possible. You have to create the OpenGL context on the HWND that is given by panel.Handle (it's an IntPtr, but can easily be cast to HWND). Be aware, that this is only working in Windows Forms, since in WPF controls do not necessarily have their own HWND. Here is another stackoverflow question, that covers a similar topic.

There are several ways how to access native C++ code from a C# application, so it might be that, depending on your needs, you will have to write a wrapper in C++/CLI around your native C++ library simmilar to (here or here).

Community
  • 1
  • 1
BDL
  • 21,052
  • 22
  • 49
  • 55
  • Doesn't this involve too much of data marshalling? – Dinesh Dec 18 '14 at 10:25
  • It involves some data marshalling. The data you have to marshal depends on your needs since you only have to marshal the functions/objects that you need to access from you C# application. – BDL Dec 18 '14 at 11:28