0
votes

I need to program a windows window with a toolstrip on top, a OpenGL window in the middle and a status line in the bottom: enter image description here

I am not to thrilled about programming the GUI elements in win32. I have some experience programming winforms in C# and would like to do this.

The problem then is how do I implement the OpenGL window? As I understand OpenTK comes with a GLControl .net component that I can add to a form.

However I already have the OpenGL code that I am going to use in C++. I would prefer not having to port this to OpenTK but instead use it directly.

How can I achieve this?

I should also explain that my window is not a main window. It is running inside another program that I am implementing a plug-in for.

2

2 Answers

1
votes

The OpenGL context is per-thread state. If you use OpenTK in C# to make a context current, then any C++ code you call from the same thread will automatically use it.

1
votes

Here is what you need to do:

  1. Isolate your C++ code into a dll.
  2. Create a C# application and create an OpenGL context. Make it the current context.
  3. Call native functions of your C++ code through the C# code using pinvoke. You can expose one or more entry points that can be called by the C# application.

I have never tried this personally but in theory this should work.