A DummyGLControl driver is now created when in DesignMode. Removes expensive GLContext initialization, and improves designer stability.

This commit is contained in:
the_fiddler 2007-09-02 08:07:09 +00:00
parent fc4e0f3698
commit 00463df2e8

View file

@ -57,44 +57,14 @@ namespace OpenTK
this.SetStyle(ControlStyles.UserPaint, true); this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
//this.SetStyle(ControlStyles.OptimizedDoubleBuffer, 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 #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 Methods ---
#region public void CreateContext()
/// <summary> /// <summary>
/// Forces the creation of the opengl rendering context. /// Forces the creation of the opengl rendering context.
/// </summary> /// </summary>
@ -105,7 +75,11 @@ namespace OpenTK
throw new ApplicationException("Attempted to create GLControl more than once."); throw new ApplicationException("Attempted to create GLControl more than once.");
} }
try if (this.DesignMode)
{
glControl = new DummyGLControl();
}
else
{ {
switch (Environment.OSVersion.Platform) switch (Environment.OSVersion.Platform)
{ {
@ -123,11 +97,6 @@ namespace OpenTK
throw new PlatformNotSupportedException("Your operating system is not currently supported. We are sorry for the inconvenience."); 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; this.Visible = true;
@ -135,6 +104,10 @@ namespace OpenTK
this.OnResize(EventArgs.Empty); this.OnResize(EventArgs.Empty);
} }
#endregion
#region public void SwapBuffers()
/// <summary> /// <summary>
/// Swaps the front and back buffers, and presents the rendered scene to the screen. /// Swaps the front and back buffers, and presents the rendered scene to the screen.
/// </summary> /// </summary>
@ -143,6 +116,10 @@ namespace OpenTK
Context.SwapBuffers(); Context.SwapBuffers();
} }
#endregion
#region public void MakeCurrent()
/// <summary> /// <summary>
/// Makes the underlying GLContext of this GLControl current. All OpenGL commands issued /// Makes the underlying GLContext of this GLControl current. All OpenGL commands issued
/// from this point are interpreted by this GLContext. /// from this point are interpreted by this GLContext.
@ -154,6 +131,8 @@ namespace OpenTK
#endregion #endregion
#endregion
#region --- Public Properties --- #region --- Public Properties ---
/// <summary> /// <summary>