Appendix 1: Frequently asked questions

[General Questions]

  1. What is the Open Toolkit exactly?
    The Open Toolkit is a C# library that:
    1. allows .Net programs to access OpenGL, OpenAL and OpenCL
    2. abstracts away the platform-specific code for window creation, input devices, and
    3. provides helper functions (math, fonts, etc)

    In the C++ world, it would be a combination of SDL/GLFW + GLEW.

  2. Is OpenTK limited to games?
    No! OpenTK is frequently used for scientific visualizations, VR, modeling/CAD software and other non-game projects.
  3. What is the difference between OpenTK and the Tao framework?
    The Tao framework is a low-level collection of bindings to various C libraries. OpenTK is a low-level OpenGL, OpenAL and OpenCL binding. While they both perform similar functions, OpenTK supports newer OpenGL versions and is more comfortable to use due to function overloading, strong-typing and generics. Consider the following code snippet:

    // OpenTK.Graphics code:
    // Tao.OpenGl code:
    Gl.glColor3ub(255, 255, 0);
    Gl.glVertex3f(0, 1, 0);

    The code is trivial, but it illustrates the difference nicely: OpenTK removes unecessary cruft ('gl', 'ub', 'f'), uses strongly-typed enums ('BeginMode') and integrates better with .Net ('Color').

    There are other differences not so readily apparent: OpenTK will not allow you to pass invalid data to OpenGL (wrong tokens or non-valuetype data); it plays better with intellisense (inline documentation, overloads, strong-types); it checks for OpenGL errors automatically in debug builds.

    All these become more important as a project grows in size.

  4. Will my Tao project run on OpenTK?
    Starting with version 0.9.9-2, OpenTK is compatible with Tao.OpenGl, Tao.OpenAl and Tao.Platform.Windows.SimpleOpenGlControl. Simply replace your Tao.OpenGl, Tao.OpenAl and Tao.Platform.Windows references with OpenTK and OpenTK.Compatibility and your project will function as before, while gaining access to all OpenTK features.
  5. OpenGL is not object-oriented. Does OpenTK change that?
    No, the Open Toolkit mirrors the raw OpenGL API. This was a conscious design decision, to avoid introducing artificial limitations. However, users have contributed object-oriented libraries built on top of OpenTK - check out the project database.
  6. I care about speed. Is OpenTK slow?
    No. OpenTK uses hand-optimized IL assembly to minimize overhead when calling OpenGL functions. However, keep in mind that the underlying runtimes (.Net/Mono) use garbage collection which introduces some unique performance considerations - refer to our documentation for more information. Performance is always a concern, so please report an issue if you believe something could run faster.
  7. Which platforms does OpenTK run on?
    OpenTK works on Windows, Linux (incl. Steam OS), Mac OS X, Android and iOS. It has also been ported to Solaris, *BSD, Raspberry PI and NaCL.
  8. Is OpenTK safe to use? How mature is it?
    OpenTK is a mature project that is safe for general use. It is being used successfully by both free and commercial projects and the library is under active development, with regular bugfix and feature releases.

[Windows.Forms & GLControl Questions]

  1. How can I make my Form fullscreen?
    Use the following code snippet:

    myForm.TopMost = true;
    myForm.FormBorderStyle = FormBorderStyle.None;
    myForm.WindowState = FormWindowState.Maximized;
  2. My GLControl.Load event isn't fired.
    Please upgrade to OpenTK 0.9.9-4 or newer.
  3. How do I use stencil, antialiasing or OpenGL 3.x with GLControl?
    Create a custom control that inherits from GLControl:

    class CustomGLControl : GLControl
        // 32bpp color, 24bpp z-depth, 8bpp stencil and 4x antialiasing
        // OpenGL version is major=3, minor=0
        public CustomGLControl()
            : base(new GraphicsMode(32, 24, 8, 4), 3, 0, GraphicsContextFlags.ForwardCompatible)
        { }

[Graphics questions]

  1. How do I save a screenshot?
    Refer to the "How to save an OpenGL rendering to disk" section in the documentation.
  2. Why is my CPU usage pegged at 100%?
    Because you are not releasing any CPU time back to the OS. Please refer to this page for more information: Avoid 100% CPU usage.