zhaoguang's picture

C++ with OpenTK

Hi all
I am a new user of OpenTK. Is there some example code of using C++ with OpenTK?

thank you



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
JTalton's picture

OpenTK is a C# wrapper around OpenGL and OpenAL and would not be good to use from C++.
If you want to use C++ with OpenGL or OpenAL there are plenty of tutorials on the net.

objarni's picture

@Zhaoguang - try with the Simple Directmedia Library for c++ and OpenGL. For OpenAL, I don't know.

the Fiddler's picture

To use OpenTK from C++ you'll have to use the C++/CLI dialect. Unfortunately, only Microsoft provides a C++/CLI compiler and the resulting code will only run on Windows (which negates one of the main benefits of OpenTK).

Here is a rough outline of a simple OpenTK program:

  1. Import the OpenTK namespace and inherit a class from OpenTK.GameWindow.
  2. In your new class, override the OnLoad, OnUpdateFrame and OnRenderFrame methods.
  3. In your main method construct a new instance of your inherited class and call the Run method.

I wish I could help you with actual code, but I have never used C++/CLI. If you are familiar with the dialect it should be relatively easy to translate that into code. Don't hesitate to ask if you need more details.