/// <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(); }
// Detects the underlying OS and runtime. static Configuration() { Toolkit.Init(); }