diff --git a/Source/GLControl/GLControl.cs b/Source/GLControl/GLControl.cs index 340b82f9..e69225cc 100644 --- a/Source/GLControl/GLControl.cs +++ b/Source/GLControl/GLControl.cs @@ -78,17 +78,20 @@ namespace OpenTK /// The GraphicsContextFlags for the OpenGL GraphicsContext. public GLControl(GraphicsMode mode, int major, int minor, GraphicsContextFlags flags) { + if (mode == null) + throw new ArgumentNullException("mode"); + SetStyle(ControlStyles.Opaque, true); SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); DoubleBuffered = false; - InitializeComponent(); - this.format = mode; this.major = major; this.minor = minor; this.flags = flags; + + InitializeComponent(); } #endregion diff --git a/Source/GLControl/GLControlFactory.cs b/Source/GLControl/GLControlFactory.cs index d854d7ae..4040fe99 100644 --- a/Source/GLControl/GLControlFactory.cs +++ b/Source/GLControl/GLControlFactory.cs @@ -38,6 +38,11 @@ namespace OpenTK { public IGLControl CreateGLControl(GraphicsMode mode, Control control) { + if (mode == null) + throw new ArgumentNullException("mode"); + if (control == null) + throw new ArgumentNullException("control"); + if (Configuration.RunningOnWindows) return new WinGLControl(mode, control); else if (Configuration.RunningOnX11) return new X11GLControl(mode, control); else if (Configuration.RunningOnMacOS) return new CarbonGLControl(mode, control);