From 00463df2e848d9168b17f49bba9687622743dcf9 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Sun, 2 Sep 2007 08:07:09 +0000 Subject: [PATCH] A DummyGLControl driver is now created when in DesignMode. Removes expensive GLContext initialization, and improves designer stability. --- Source/OpenTK/GLControl.cs | 61 +++++++++++++------------------------- 1 file changed, 20 insertions(+), 41 deletions(-) diff --git a/Source/OpenTK/GLControl.cs b/Source/OpenTK/GLControl.cs index fc7de2da..720ca944 100644 --- a/Source/OpenTK/GLControl.cs +++ b/Source/OpenTK/GLControl.cs @@ -57,44 +57,14 @@ namespace OpenTK this.SetStyle(ControlStyles.UserPaint, true); this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); //this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); - - this.Disposed += new EventHandler(GLControl_Disposed); - - //Debug.Print("Creating GLControl."); - //this.CreateControl(); - } - - void GLControl_Disposed(object sender, EventArgs e) - { - //glControl.Context.Dispose(); - //Application.ExitThread(); } #endregion - /* - CreateParams @params; - protected override CreateParams CreateParams - { - get - { - if (@params == null) - { - @params = base.CreateParams; - //@params.ClassStyle = (int) - // (OpenTK.Platform.Windows.API.WindowClassStyle.OwnDC | - // OpenTK.Platform.Windows.API.WindowClassStyle.HRedraw | - // OpenTK.Platform.Windows.API.WindowClassStyle.VRedraw); - //@params.Style = (int) - // (OpenTK.Platform.Windows.API.WindowStyle.ClipChildren); - // OpenTK.Platform.Windows.API.WindowStyle.ClipSiblings); - //@params.ExStyle = OpenTK.Platform.Windows.API.ExtendedWindowStyle. - } - return @params; - } - } - */ + #region --- Public Methods --- + #region public void CreateContext() + /// /// Forces the creation of the opengl rendering context. /// @@ -105,7 +75,11 @@ namespace OpenTK throw new ApplicationException("Attempted to create GLControl more than once."); } - try + if (this.DesignMode) + { + glControl = new DummyGLControl(); + } + else { switch (Environment.OSVersion.Platform) { @@ -113,21 +87,16 @@ namespace OpenTK case PlatformID.Win32Windows: glControl = new OpenTK.Platform.Windows.WinGLControl(this, new DisplayMode(Width, Height)); break; - + case PlatformID.Unix: case (PlatformID)128: // some older versions of Mono reported 128. glControl = new OpenTK.Platform.X11.X11GLControl(this); break; - + default: throw new PlatformNotSupportedException("Your operating system is not currently supported. We are sorry for the inconvenience."); } } - catch (Exception e) - { - Debug.Print("Could not create GLControl, error: {0}", e.ToString()); - throw; - } this.Visible = true; @@ -135,6 +104,10 @@ namespace OpenTK this.OnResize(EventArgs.Empty); } + #endregion + + #region public void SwapBuffers() + /// /// Swaps the front and back buffers, and presents the rendered scene to the screen. /// @@ -143,6 +116,10 @@ namespace OpenTK Context.SwapBuffers(); } + #endregion + + #region public void MakeCurrent() + /// /// Makes the underlying GLContext of this GLControl current. All OpenGL commands issued /// from this point are interpreted by this GLContext. @@ -154,6 +131,8 @@ namespace OpenTK #endregion + #endregion + #region --- Public Properties --- ///