Init() public static method

Initializes OpenTK. This method is necessary only if you are using OpenTK alongside a different windowing toolkit (e.g. GTK#) and should be the very first method called by your application (i.e. calling this method should be the very first statement executed by the "Main" method).
Some windowing toolkits do not configure the underlying platform correctly or configure it in a way that is incompatible with OpenTK. Calling this method first ensures that OpenTK is given the chance to initialize itself and configure the platform correctly.
public static Init ( ) : IDisposable
return IDisposable
示例#1
0
        /// <summary>
        /// Constructs a new instance with the specified GraphicsMode.
        /// </summary>
        /// <param name="mode">The OpenTK.Graphics.GraphicsMode of the control.</param>
        /// <param name="major">The major version for the OpenGL GraphicsContext.</param>
        /// <param name="minor">The minor version for the OpenGL GraphicsContext.</param>
        /// <param name="flags">The GraphicsContextFlags for the OpenGL GraphicsContext.</param>
        public GLControl(GraphicsMode mode, int major, int minor, GraphicsContextFlags flags)
        {
            if (mode == null)
            {
                throw new ArgumentNullException(nameof(mode));
            }

            // SDL does not currently support embedding
            // on external windows. If Open.Toolkit is not yet
            // initialized, we'll try to request a native backend
            // that supports embedding.
            // Most people are using GLControl through the
            // WinForms designer in Visual Studio. This approach
            // works perfectly in that case.
            Toolkit.Init(new ToolkitOptions
            {
                Backend = PlatformBackend.PreferNative
            });

            SetStyle(ControlStyles.Opaque, true);
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            DoubleBuffered = false;

            _format = mode;
            _major  = major;
            _minor  = minor;
            _flags  = flags;

            // Note: the DesignMode property may be incorrect when nesting controls.
            // We use LicenseManager.UsageMode as a workaround (this only works in
            // the constructor).
            _designMode =
                DesignMode ||
                LicenseManager.UsageMode == LicenseUsageMode.Designtime;

            InitializeComponent();
        }
示例#2
0
 // Detects the underlying OS and runtime.
 static Configuration()
 {
     Toolkit.Init();
 }